1CURLINFO_CERTINFO(3)       curl_easy_getinfo options      CURLINFO_CERTINFO(3)
2
3
4

NAME

6       CURLINFO_CERTINFO - get the TLS certificate chain
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CERTINFO,
12                                  struct curl_certinfo **chainp);
13

DESCRIPTION

15       Pass  a  pointer to a 'struct curl_certinfo *' and you'll 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

PROTOCOLS

25       All TLS-based
26

EXAMPLE

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

AVAILABILITY

59       This option is only working in libcurl built with OpenSSL, NSS,  Schanā€
60       nel or GSKit support. Schannel support added in 7.50.0
61
62       Added in 7.19.1
63

RETURN VALUE

65       Returns  CURLE_OK  if the option is supported, and CURLE_UNKNOWN_OPTION
66       if not.
67

SEE ALSO

69       curl_easy_getinfo(3), curl_easy_setopt(3),
70
71
72
73libcurl 7.76.1                 November 04, 2020          CURLINFO_CERTINFO(3)
Impressum