void *user_data)
{
struct curl_tls_ctx *ctx = user_data;
- struct ssl_config_data *ssl_config = Curl_ssl_cf_get_config(cf, data);
#ifdef USE_OPENSSL
#if defined(OPENSSL_IS_BORINGSSL) || defined(OPENSSL_IS_AWSLC)
return CURLE_FAILED_INIT;
}
#endif /* !OPENSSL_IS_BORINGSSL && !OPENSSL_IS_AWSLC */
- if(ssl_config->primary.cache_session) {
+ if(Curl_ssl_scache_use(cf, data)) {
/* Enable the session cache because it is a prerequisite for the
* "new session" callback. Use the "external storage" mode to prevent
* OpenSSL from creating an internal session cache.
failf(data, "ngtcp2_crypto_gnutls_configure_client_session failed");
return CURLE_FAILED_INIT;
}
- if(ssl_config->primary.cache_session) {
+ if(Curl_ssl_scache_use(cf, data)) {
gnutls_handshake_set_hook_function(ctx->gtls.session,
GNUTLS_HANDSHAKE_ANY, GNUTLS_HOOK_POST,
quic_gtls_handshake_cb);
failf(data, "ngtcp2_crypto_wolfssl_configure_client_context failed");
return CURLE_FAILED_INIT;
}
- if(ssl_config->primary.cache_session) {
+ if(Curl_ssl_scache_use(cf, data)) {
/* Register to get notified when a new session is received */
wolfSSL_CTX_sess_set_new_cb(ctx->wssl.ssl_ctx, wssl_quic_new_session_cb);
}
unsigned char *quic_tp,
size_t quic_tp_len)
{
- struct ssl_config_data *ssl_config = Curl_ssl_cf_get_config(cf, data);
struct Curl_ssl_session *sc_session;
unsigned char *sdata, *qtp_clone = NULL;
size_t sdata_len = 0;
size_t earlydata_max = 0;
CURLcode result = CURLE_OK;
- if(!ssl_config->primary.cache_session)
+ if(!Curl_ssl_scache_use(cf, data))
return CURLE_OK;
/* we always unconditionally get the session id here, as even if we
#endif
/* Check if there is a cached ID we can/should use here! */
- if(ssl_config->primary.cache_session) {
+ if(Curl_ssl_scache_use(cf, data)) {
struct Curl_ssl_session *sc_session = NULL;
CURLcode result;
struct ssl_connect_data *connssl = cf->ctx;
struct mbed_ssl_backend_data *backend =
(struct mbed_ssl_backend_data *)connssl->backend;
- struct ssl_config_data *ssl_config = Curl_ssl_cf_get_config(cf, data);
mbedtls_ssl_session session;
bool msession_alloced = FALSE;
struct Curl_ssl_session *sc_session = NULL;
int ret;
DEBUGASSERT(backend);
- if(!ssl_config->primary.cache_session)
+ if(!Curl_ssl_scache_use(cf, data))
return CURLE_OK;
mbedtls_ssl_session_init(&session);
unsigned char *quic_tp,
size_t quic_tp_len)
{
- const struct ssl_config_data *config;
unsigned char *der_session_buf = NULL;
unsigned char *qtp_clone = NULL;
CURLcode result = CURLE_OK;
if(!cf || !data)
goto out;
- config = Curl_ssl_cf_get_config(cf, data);
- if(config->primary.cache_session) {
+ if(Curl_ssl_scache_use(cf, data)) {
struct Curl_ssl_session *sc_session = NULL;
size_t der_session_size;
unsigned char *der_session_ptr;
Curl_alpn_copy(&alpns, alpns_requested);
octx->reused_session = FALSE;
- if(ssl_config->primary.cache_session && !conn_cfg->verifystatus) {
+ if(Curl_ssl_scache_use(cf, data) && !conn_cfg->verifystatus) {
struct Curl_ssl_session *scs = NULL;
result = Curl_ssl_scache_take(cf, data, peer->scache_key, &scs);
}
}
#else
+ (void)ssl_config;
(void)sess_reuse_cb;
#endif
}
backend->cred = NULL;
/* check for an existing reusable credential handle */
- if(ssl_config->primary.cache_session) {
+ if(Curl_ssl_scache_use(cf, data)) {
struct Curl_schannel_cred *old_cred;
Curl_ssl_scache_lock(data);
old_cred = Curl_ssl_scache_get_obj(cf, data, connssl->peer.scache_key);
struct ssl_connect_data *connssl = cf->ctx;
struct schannel_ssl_backend_data *backend =
(struct schannel_ssl_backend_data *)connssl->backend;
- struct ssl_config_data *ssl_config = Curl_ssl_cf_get_config(cf, data);
CURLcode result = CURLE_OK;
SECURITY_STATUS sspi_status = SEC_E_OK;
CERT_CONTEXT *ccert_context = NULL;
#endif
/* save the current session data for possible reuse */
- if(ssl_config->primary.cache_session) {
+ if(Curl_ssl_scache_use(cf, data)) {
Curl_ssl_scache_lock(data);
/* Up ref count since call takes ownership */
backend->cred->refcount++;
}
}
+bool Curl_ssl_scache_use(struct Curl_cfilter *cf, struct Curl_easy *data)
+{
+ if(cf_ssl_scache_get(data)) {
+ struct ssl_config_data *ssl_config = Curl_ssl_cf_get_config(cf, data);
+ return ssl_config ? ssl_config->primary.cache_session : FALSE;
+ }
+ return FALSE;
+}
+
/* Lock shared SSL session data */
void Curl_ssl_scache_lock(struct Curl_easy *data)
{
const char *tls_id,
char **ppeer_key);
+/* Return if there is a session cache shall be used.
+ * An ssl session might not be configured or not available for
+ * "connect-only" transfers.
+ */
+bool Curl_ssl_scache_use(struct Curl_cfilter *cf, struct Curl_easy *data);
+
/* Lock session cache mutex.
* Call this before calling other Curl_ssl_*session* functions
* Caller should unlock this mutex as soon as possible, as it may block
}
#endif
- if(ssl_config->primary.cache_session && (transport != TRNSPRT_QUIC)) {
+ if(Curl_ssl_scache_use(cf, data) && (transport != TRNSPRT_QUIC)) {
/* Register to get notified when a new session is received */
wolfSSL_CTX_sess_set_new_cb(wctx->ssl_ctx, wssl_vtls_new_session_cb);
}
#endif
/* Check if there is a cached ID we can/should use here! */
- if(ssl_config->primary.cache_session) {
+ if(Curl_ssl_scache_use(cf, data)) {
/* Set session from cache if there is one */
(void)wssl_setup_session(cf, data, wctx, &alpns,
peer->scache_key, sess_reuse_cb);