From 2e0a3b935c8bc8fc8e3267aae7ad50f452ecadb3 Mon Sep 17 00:00:00 2001 From: Jay Satiro Date: Sat, 27 Feb 2016 19:01:00 -0500 Subject: [PATCH] getinfo: Add support for mbedTLS TLS session info .. and preprocessor check TLS session info is defined for all backends. --- docs/libcurl/opts/CURLINFO_TLS_SESSION.3 | 2 +- docs/libcurl/opts/CURLINFO_TLS_SSL_PTR.3 | 14 ++++++----- lib/getinfo.c | 30 ++++++++++-------------- 3 files changed, 22 insertions(+), 24 deletions(-) diff --git a/docs/libcurl/opts/CURLINFO_TLS_SESSION.3 b/docs/libcurl/opts/CURLINFO_TLS_SESSION.3 index b1bef0e6e..7c86bedfe 100644 --- a/docs/libcurl/opts/CURLINFO_TLS_SESSION.3 +++ b/docs/libcurl/opts/CURLINFO_TLS_SESSION.3 @@ -5,7 +5,7 @@ .\" * | (__| |_| | _ <| |___ .\" * \___|\___/|_| \_\_____| .\" * -.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. +.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, , et al. .\" * .\" * This software is licensed as described in the file COPYING, which .\" * you should have received as part of this distribution. The terms diff --git a/docs/libcurl/opts/CURLINFO_TLS_SSL_PTR.3 b/docs/libcurl/opts/CURLINFO_TLS_SSL_PTR.3 index 6d984e34d..c9df999d9 100644 --- a/docs/libcurl/opts/CURLINFO_TLS_SSL_PTR.3 +++ b/docs/libcurl/opts/CURLINFO_TLS_SSL_PTR.3 @@ -5,11 +5,11 @@ .\" * | (__| |_| | _ <| |___ .\" * \___|\___/|_| \_\_____| .\" * -.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, , et al. +.\" * Copyright (C) 1998 - 2016, Daniel Stenberg, , et al. .\" * .\" * This software is licensed as described in the file COPYING, which .\" * you should have received as part of this distribution. The terms -.\" * are also available at http://curl.haxx.se/docs/copyright.html. +.\" * are also available at https://curl.haxx.se/docs/copyright.html. .\" * .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell .\" * copies of the Software, and permit persons to whom the Software is @@ -56,10 +56,10 @@ struct curl_tlssessioninfo { The \fIbackend\fP struct member is one of the defines in the CURLSSLBACKEND_* series: CURLSSLBACKEND_NONE (when built without TLS support), -CURLSSLBACKEND_OPENSSL, CURLSSLBACKEND_GNUTLS, CURLSSLBACKEND_NSS, -CURLSSLBACKEND_GSKIT, CURLSSLBACKEND_POLARSSL, CURLSSLBACKEND_CYASSL, -CURLSSLBACKEND_SCHANNEL, CURLSSLBACKEND_DARWINSSL or -CURLSSLBACKEND_AXTLS. (Note that the OpenSSL forks are all reported as just +CURLSSLBACKEND_AXTLS, CURLSSLBACKEND_CYASSL, CURLSSLBACKEND_DARWINSSL, +CURLSSLBACKEND_GNUTLS, CURLSSLBACKEND_GSKIT, CURLSSLBACKEND_MBEDTLS, +CURLSSLBACKEND_NSS, CURLSSLBACKEND_OPENSSL, CURLSSLBACKEND_POLARSSL or +CURLSSLBACKEND_SCHANNEL. (Note that the OpenSSL forks are all reported as just OpenSSL here.) The \fIinternals\fP struct member will point to a TLS library specific pointer @@ -81,6 +81,8 @@ as well: .RS .IP axTLS SSL * +.IP mbedTLS +mbedtls_ssl_session * .IP PolarSSL ssl_session * .IP Secure Channel ("WinSSL") diff --git a/lib/getinfo.c b/lib/getinfo.c index 2508b291f..117d513a5 100644 --- a/lib/getinfo.c +++ b/lib/getinfo.c @@ -296,35 +296,31 @@ static CURLcode getinfo_slist(struct SessionHandle *data, CURLINFO info, unsigned int i; for(i = 0; i < (sizeof(conn->ssl) / sizeof(conn->ssl[0])); ++i) { if(conn->ssl[i].use) { -#ifdef USE_AXTLS +#if defined(USE_AXTLS) tsi->internals = (void *)conn->ssl[i].ssl; -#endif -#ifdef USE_CYASSL +#elif defined(USE_CYASSL) tsi->internals = (void *)conn->ssl[i].handle; -#endif -#ifdef USE_DARWINSSL +#elif defined(USE_DARWINSSL) tsi->internals = (void *)conn->ssl[i].ssl_ctx; -#endif -#ifdef USE_GNUTLS +#elif defined(USE_GNUTLS) tsi->internals = (void *)conn->ssl[i].session; -#endif -#ifdef USE_GSKIT +#elif defined(USE_GSKIT) tsi->internals = (void *)conn->ssl[i].handle; -#endif -#ifdef USE_NSS +#elif defined(USE_MBEDTLS) + tsi->internals = (void *)conn->ssl[i].ssn; +#elif defined(USE_NSS) tsi->internals = (void *)conn->ssl[i].handle; -#endif -#ifdef USE_OPENSSL +#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); -#endif -#ifdef USE_POLARSSL +#elif defined(USE_POLARSSL) tsi->internals = (void *)&conn->ssl[i].ssn; -#endif -#ifdef USE_SCHANNEL +#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 break; }