getinfo: access SSL internals via Curl_ssl

In the ongoing endeavor to abstract out all SSL backend-specific
functionality, this is the next step: Instead of hard-coding how the
different SSL backends access their internal data in getinfo.c, let's
implement backend-specific functions to do that task.

This will also allow for switching SSL backends as a runtime option.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin 2017-06-23 16:05:26 +02:00 committed by Daniel Stenberg
parent 118b074fba
commit 69039fd1fa
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
12 changed files with 88 additions and 26 deletions

View file

@ -360,46 +360,25 @@ static CURLcode getinfo_slist(struct Curl_easy *data, CURLINFO info,
struct curl_tlssessioninfo **tsip = (struct curl_tlssessioninfo **)
param_slistp;
struct curl_tlssessioninfo *tsi = &data->tsi;
#ifdef USE_SSL
struct connectdata *conn = data->easy_conn;
#endif
*tsip = tsi;
tsi->backend = Curl_ssl_backend();
tsi->internals = NULL;
#ifdef USE_SSL
if(conn && tsi->backend != CURLSSLBACKEND_NONE) {
unsigned int i;
for(i = 0; i < (sizeof(conn->ssl) / sizeof(conn->ssl[0])); ++i) {
if(conn->ssl[i].use) {
#if defined(USE_AXTLS)
tsi->internals = (void *)conn->ssl[i].ssl;
#elif defined(USE_CYASSL)
tsi->internals = (void *)conn->ssl[i].handle;
#elif defined(USE_DARWINSSL)
tsi->internals = (void *)conn->ssl[i].ssl_ctx;
#elif defined(USE_GNUTLS)
tsi->internals = (void *)conn->ssl[i].session;
#elif defined(USE_GSKIT)
tsi->internals = (void *)conn->ssl[i].handle;
#elif defined(USE_MBEDTLS)
tsi->internals = (void *)&conn->ssl[i].ssl;
#elif defined(USE_NSS)
tsi->internals = (void *)conn->ssl[i].handle;
#elif defined(USE_OPENSSL)
/* Legacy: CURLINFO_TLS_SESSION must return an SSL_CTX pointer. */
tsi->internals = ((info == CURLINFO_TLS_SESSION) ?
(void *)conn->ssl[i].ctx :
(void *)conn->ssl[i].handle);
#elif defined(USE_POLARSSL)
tsi->internals = (void *)&conn->ssl[i].ssl;
#elif defined(USE_SCHANNEL)
tsi->internals = (void *)&conn->ssl[i].ctxt->ctxt_handle;
#elif defined(USE_SSL)
#error "SSL backend specific information missing for CURLINFO_TLS_SSL_PTR"
#endif
tsi->internals = Curl_ssl->get_internals(&conn->ssl[i], info);
break;
}
}
}
#endif
}
break;
default: