GNURLINFO_TLS_SESSION(3)

πŸ“¦ version 7.72.0, in nixos 26.05, nixpkgs unstable

✨ GNURLINFO_TLS_SESSION ✨

okay so bestie, we need to talk about this lil manual page from the gnurl world πŸ’… it's giving legacy energy but we still gotta know it, y'know?


πŸŽ€ NAME πŸŽ€

CURLINFO_TLS_SESSION β€” get TLS session info, bestie! it's literally right there in the name πŸ¦‹


🌸 SYNOPSIS 🌸

#include <gnurl/curl.h>

CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_TLS_SESSION,
                           struct curl_tlssessioninfo **session);

πŸ’– DESCRIPTION πŸ’–

okay so first thing you need to know: this option has been totally superseded by CURLINFO_TLS_SSL_PTR(3) which showed up in 7.48.0. like, it's the newer cooler version ✨ the only reason you'd ever reach for this one instead is if you're stuck with a version of libcurl earlier than 7.48.0. and we respect the retro vibes but also… upgrade if u can πŸ™ˆ

this option is exactly the same as CURLINFO_TLS_SSL_PTR(3) except in the case of OpenSSL. and here's where it gets spicy πŸ”₯ β€” if the session backend is CURLSSLBACKEND_OPENSSL, the session internals pointer varies depending on which option you use:

  • CURLINFO_TLS_SESSION β€” OpenSSL session internals is SSL_CTX *.
  • CURLINFO_TLS_SSL_PTR β€” OpenSSL session internals is SSL *.

so here's the tea β˜• β€” you can obtain an SSL_CTX pointer from an SSL pointer using the OpenSSL function SSL_get_SSL_CTX. therefore, unless you need compatibility with older versions of libcurl, use CURLINFO_TLS_SSL_PTR(3). that's the main character energy option πŸ‘‘ refer to that document for more info, bestie πŸ’œ


πŸ¦‹ PROTOCOLS πŸ¦‹

All TLS-based β€” that's it, that's the whole vibe 🌈


⭐ EXAMPLE ⭐

here's how you actually use it, no cap:

CURL *curl = curl_easy_init();
if(curl) {
  CURLcode res;
  struct curl_tlssessioninfo *tls;
  curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
  res = curl_easy_perform(curl);
  curl_easy_getinfo(curl, CURLINFO_TLS_SESSION, &tls);
  curl_easy_cleanup(curl);
}

🧚 AVAILABILITY 🧚

Added in 7.34.0, and supported OpenSSL, GnuTLS, NSS and gskit only up until 7.48.0 was released. so yeah, it had its moment πŸ’€


πŸ‘‘ RETURN VALUE πŸ‘‘

Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. simple as that 🫢


🌟 SEE ALSO 🌟


and that's the whole page, bestie! ✨ this lil manual page you've been reading is from libcurl 7.44.0 and it's dated 12 Sep 2015 β€” absolute vintage icon behavior honestly πŸŽ€ go forth and use CURLINFO_TLS_SSL_PTR(3) like I told you πŸ’–

πŸ“¦ where this page comes from