1CURLINFO_CERTINFO(3) curl_easy_getinfo options CURLINFO_CERTINFO(3)
2
3
4
6 CURLINFO_CERTINFO - get the TLS certificate chain
7
9 #include <curl/curl.h>
10
11 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CERTINFO,
12 struct curl_certinfo **chainp);
13
15 Pass a pointer to a 'struct curl_certinfo *' and you will get it set to
16 point to a struct that holds a number of linked lists with info about
17 the certificate chain, assuming you had CURLOPT_CERTINFO(3) enabled
18 when the request was made. The struct reports how many certs it found
19 and then you can extract info for each of those certs by following the
20 linked lists. The info chain is provided in a series of data in the
21 format "name:content" where the content is for the specific named data.
22 See also the certinfo.c example.
23
25 All TLS-based
26
28 curl = curl_easy_init();
29 if(curl) {
30 curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");
31
32 /* connect to any HTTPS site, trusted or not */
33 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
34 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
35
36 curl_easy_setopt(curl, CURLOPT_CERTINFO, 1L);
37
38 res = curl_easy_perform(curl);
39
40 if (!res) {
41 struct curl_certinfo *ci;
42 res = curl_easy_getinfo(curl, CURLINFO_CERTINFO, &ci);
43
44 if (!res) {
45 printf("%d certs!\n", ci->num_of_certs);
46
47 for(i = 0; i < ci->num_of_certs; i++) {
48 struct curl_slist *slist;
49
50 for(slist = ci->certinfo[i]; slist; slist = slist->next)
51 printf("%s\n", slist->data);
52 }
53 }
54 }
55 curl_easy_cleanup(curl);
56 }
57
59 This option is only working in libcurl built with OpenSSL, NSS, Schanā
60 nel, GSKit or Secure Transport support. Schannel support added in
61 7.50.0. Secure Transport support added in 7.79.0.
62
63 Added in 7.19.1
64
66 Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION
67 if not.
68
70 curl_easy_getinfo(3), curl_easy_setopt(3),
71
72
73
74libcurl 7.85.0 May 17, 2022 CURLINFO_CERTINFO(3)