GNURLINFO_CERTINFO(3)
π NAME π
okay bestie, welcome to the GNURLINFO_CERTINFO(3) page β this is the curl_easy_getinfo options corner, and todayβs main character is CURLINFO_CERTINFO, aka get the TLS certificate chain. periodt. π
β¨ SYNOPSIS β¨
#include <gnurl/curl.h>
CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CERTINFO,
struct curl_certinfo **chainp);
π DESCRIPTION π
So hereβs the vibe: you pass a pointer to a struct curl_certinfo * and youβll get it set to point to a struct that holds a number of linked lists with info about the certificate chain β assuming you had CURLOPT_CERTINFO(3) enabled when the request was made. The struct reports how many certs it found, and then you can extract info for each of those certs by following the linked lists. The info chain is provided in a series of data in the format "name:content" where the content is for the specific named data. Also go peek at the certinfo.c example, iykyk. π¦
π PROTOCOLS π
All TLS-based. Thatβs it, thatβs the protocol tea. π
π₯ EXAMPLE π₯
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");
/* connect to any HTTPS site, trusted or not */
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_CERTINFO, 1L);
res = curl_easy_perform(curl);
if (!res) {
struct curl_certinfo *ci;
res = curl_easy_getinfo(curl, CURLINFO_CERTINFO, &ci);
if (!res) {
printf("%d certs!\n", ci->num_of_certs);
for(i = 0; i < ci->num_of_certs; i++) {
struct curl_slist *slist;
for(slist = ci->certinfo[i]; slist; slist = slist->next)
printf("%s\n", slist->data);
}
}
}
curl_easy_cleanup(curl);
}
β AVAILABILITY β
This option is only working in libcurl built with OpenSSL, NSS, Schannel or GSKit support. Schannel support added in 7.50.0. Added in 7.19.1. slay. β¨
π RETURN VALUE π
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. no cap. π«Ά
π SEE ALSO π
xoxo, your Unix bestie π β this GNURLINFO_CERTINFO(3) page is from libcurl 7.44.0, dated 12 Sep 2015. mwah. π
π¦ where this page comes from
- nixos 26.05: libgnurl 7.72.0
- nixpkgs unstable: libgnurl 7.72.0
- Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms