Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <stdio.h>
00027
00028 #include <curl/curl.h>
00029
00030 static size_t wrfu(void *ptr, size_t size, size_t nmemb, void *stream)
00031 {
00032 (void)stream;
00033 (void)ptr;
00034 return size * nmemb;
00035 }
00036
00037 int main(void)
00038 {
00039 CURL *curl;
00040 CURLcode res;
00041
00042 curl_global_init(CURL_GLOBAL_DEFAULT);
00043
00044 curl = curl_easy_init();
00045 if(curl) {
00046 curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");
00047
00048 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, wrfu);
00049
00050 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
00051 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
00052
00053 curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);
00054 curl_easy_setopt(curl, CURLOPT_CERTINFO, 1L);
00055
00056 res = curl_easy_perform(curl);
00057
00058 if(!res) {
00059 union {
00060 struct curl_slist *to_info;
00061 struct curl_certinfo *to_certinfo;
00062 } ptr;
00063
00064 ptr.to_info = NULL;
00065
00066 res = curl_easy_getinfo(curl, CURLINFO_CERTINFO, &ptr.to_info);
00067
00068 if(!res && ptr.to_info) {
00069 int i;
00070
00071 printf("%d certs!\n", ptr.to_certinfo->num_of_certs);
00072
00073 for(i = 0; i < ptr.to_certinfo->num_of_certs; i++) {
00074 struct curl_slist *slist;
00075
00076 for(slist = ptr.to_certinfo->certinfo[i]; slist; slist = slist->next)
00077 printf("%s\n", slist->data);
00078
00079 }
00080 }
00081
00082 }
00083
00084 curl_easy_cleanup(curl);
00085 }
00086
00087 curl_global_cleanup();
00088
00089 return 0;
00090 }