CURLINFO_TLS_SESSION.md (2007B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLINFO_TLS_SESSION 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLINFO_TLS_SSL_PTR (3) 9 - curl_easy_getinfo (3) 10 - curl_easy_setopt (3) 11 Protocol: 12 - TLS 13 TLS-backend: 14 - OpenSSL 15 - GnuTLS 16 Added-in: 7.34.0 17 --- 18 19 # NAME 20 21 CURLINFO_TLS_SESSION - get TLS session info 22 23 # SYNOPSIS 24 25 ~~~c 26 #include <curl/curl.h> 27 28 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_TLS_SESSION, 29 struct curl_tlssessioninfo **session); 30 ~~~ 31 32 # DESCRIPTION 33 34 **This option has been superseded** by CURLINFO_TLS_SSL_PTR(3) which 35 was added in 7.48.0. The only reason you would use this option instead is if 36 you could be using a version of libcurl earlier than 7.48.0. 37 38 This option is exactly the same as CURLINFO_TLS_SSL_PTR(3) except in the 39 case of OpenSSL. If the session *backend* is CURLSSLBACKEND_OPENSSL the 40 session *internals* pointer varies depending on the option: 41 42 CURLINFO_TLS_SESSION(3) OpenSSL session *internals* is **SSL_CTX ***. 43 44 CURLINFO_TLS_SSL_PTR(3) OpenSSL session *internals* is **SSL ***. 45 46 You can obtain an **SSL_CTX** pointer from an SSL pointer using OpenSSL 47 function *SSL_get_SSL_CTX(3)*. Therefore unless you need compatibility 48 with older versions of libcurl use CURLINFO_TLS_SSL_PTR(3). Refer to 49 that document for more information. 50 51 # %PROTOCOLS% 52 53 # EXAMPLE 54 55 ~~~c 56 int main(void) 57 { 58 CURL *curl = curl_easy_init(); 59 if(curl) { 60 CURLcode res; 61 struct curl_tlssessioninfo *tls; 62 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 63 res = curl_easy_perform(curl); 64 if(res) 65 printf("error: %s\n", curl_easy_strerror(res)); 66 curl_easy_getinfo(curl, CURLINFO_TLS_SESSION, &tls); 67 curl_easy_cleanup(curl); 68 } 69 } 70 ~~~ 71 72 # DEPRECATED 73 74 Deprecated since 7.48.0 75 76 # %AVAILABILITY% 77 78 # RETURN VALUE 79 80 curl_easy_getinfo(3) returns a CURLcode indicating success or error. 81 82 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 83 libcurl-errors(3).