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