getinfo: Add support for mbedTLS TLS session info

.. and preprocessor check TLS session info is defined for all backends.
This commit is contained in:
Jay Satiro 2016-02-27 19:01:00 -05:00
parent 6f1735926f
commit 2e0a3b935c
3 changed files with 22 additions and 24 deletions

View File

@ -5,7 +5,7 @@
.\" * | (__| |_| | _ <| |___ .\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____| .\" * \___|\___/|_| \_\_____|
.\" * .\" *
.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. .\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * .\" *
.\" * This software is licensed as described in the file COPYING, which .\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms .\" * you should have received as part of this distribution. The terms

View File

@ -5,11 +5,11 @@
.\" * | (__| |_| | _ <| |___ .\" * | (__| |_| | _ <| |___
.\" * \___|\___/|_| \_\_____| .\" * \___|\___/|_| \_\_____|
.\" * .\" *
.\" * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. .\" * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
.\" * .\" *
.\" * This software is licensed as described in the file COPYING, which .\" * This software is licensed as described in the file COPYING, which
.\" * you should have received as part of this distribution. The terms .\" * 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 .\" * 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 .\" * 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_* The \fIbackend\fP struct member is one of the defines in the CURLSSLBACKEND_*
series: CURLSSLBACKEND_NONE (when built without TLS support), series: CURLSSLBACKEND_NONE (when built without TLS support),
CURLSSLBACKEND_OPENSSL, CURLSSLBACKEND_GNUTLS, CURLSSLBACKEND_NSS, CURLSSLBACKEND_AXTLS, CURLSSLBACKEND_CYASSL, CURLSSLBACKEND_DARWINSSL,
CURLSSLBACKEND_GSKIT, CURLSSLBACKEND_POLARSSL, CURLSSLBACKEND_CYASSL, CURLSSLBACKEND_GNUTLS, CURLSSLBACKEND_GSKIT, CURLSSLBACKEND_MBEDTLS,
CURLSSLBACKEND_SCHANNEL, CURLSSLBACKEND_DARWINSSL or CURLSSLBACKEND_NSS, CURLSSLBACKEND_OPENSSL, CURLSSLBACKEND_POLARSSL or
CURLSSLBACKEND_AXTLS. (Note that the OpenSSL forks are all reported as just CURLSSLBACKEND_SCHANNEL. (Note that the OpenSSL forks are all reported as just
OpenSSL here.) OpenSSL here.)
The \fIinternals\fP struct member will point to a TLS library specific pointer The \fIinternals\fP struct member will point to a TLS library specific pointer
@ -81,6 +81,8 @@ as well:
.RS .RS
.IP axTLS .IP axTLS
SSL * SSL *
.IP mbedTLS
mbedtls_ssl_session *
.IP PolarSSL .IP PolarSSL
ssl_session * ssl_session *
.IP Secure Channel ("WinSSL") .IP Secure Channel ("WinSSL")

View File

@ -296,35 +296,31 @@ static CURLcode getinfo_slist(struct SessionHandle *data, CURLINFO info,
unsigned int i; unsigned int i;
for(i = 0; i < (sizeof(conn->ssl) / sizeof(conn->ssl[0])); ++i) { for(i = 0; i < (sizeof(conn->ssl) / sizeof(conn->ssl[0])); ++i) {
if(conn->ssl[i].use) { if(conn->ssl[i].use) {
#ifdef USE_AXTLS #if defined(USE_AXTLS)
tsi->internals = (void *)conn->ssl[i].ssl; tsi->internals = (void *)conn->ssl[i].ssl;
#endif #elif defined(USE_CYASSL)
#ifdef USE_CYASSL
tsi->internals = (void *)conn->ssl[i].handle; tsi->internals = (void *)conn->ssl[i].handle;
#endif #elif defined(USE_DARWINSSL)
#ifdef USE_DARWINSSL
tsi->internals = (void *)conn->ssl[i].ssl_ctx; tsi->internals = (void *)conn->ssl[i].ssl_ctx;
#endif #elif defined(USE_GNUTLS)
#ifdef USE_GNUTLS
tsi->internals = (void *)conn->ssl[i].session; tsi->internals = (void *)conn->ssl[i].session;
#endif #elif defined(USE_GSKIT)
#ifdef USE_GSKIT
tsi->internals = (void *)conn->ssl[i].handle; tsi->internals = (void *)conn->ssl[i].handle;
#endif #elif defined(USE_MBEDTLS)
#ifdef USE_NSS tsi->internals = (void *)conn->ssl[i].ssn;
#elif defined(USE_NSS)
tsi->internals = (void *)conn->ssl[i].handle; tsi->internals = (void *)conn->ssl[i].handle;
#endif #elif defined(USE_OPENSSL)
#ifdef USE_OPENSSL
/* Legacy: CURLINFO_TLS_SESSION must return an SSL_CTX pointer. */ /* Legacy: CURLINFO_TLS_SESSION must return an SSL_CTX pointer. */
tsi->internals = ((info == CURLINFO_TLS_SESSION) ? tsi->internals = ((info == CURLINFO_TLS_SESSION) ?
(void *)conn->ssl[i].ctx : (void *)conn->ssl[i].ctx :
(void *)conn->ssl[i].handle); (void *)conn->ssl[i].handle);
#endif #elif defined(USE_POLARSSL)
#ifdef USE_POLARSSL
tsi->internals = (void *)&conn->ssl[i].ssn; tsi->internals = (void *)&conn->ssl[i].ssn;
#endif #elif defined(USE_SCHANNEL)
#ifdef USE_SCHANNEL
tsi->internals = (void *)&conn->ssl[i].ctxt->ctxt_handle; 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 #endif
break; break;
} }