diff options
author | Daniel Stenberg <daniel@haxx.se> | 2012-12-11 23:31:45 +0100 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2012-12-11 23:31:45 +0100 |
commit | 50d7397ea54df79e403649d1e37d002eb52d268f (patch) | |
tree | 6b6eed95d3d4b69cd26e0b2377fa934d5ea99c09 /docs/examples/certinfo.c | |
parent | a3d6368c690b943e92082951e8c5fc3ef2d76c12 (diff) | |
parent | 4deb52831a071bc83cefb4871764281a5c32f902 (diff) | |
download | curl-multi-always.tar.gz |
Merge branch 'multi2' into multi-alwaysmulti-always
Diffstat (limited to 'docs/examples/certinfo.c')
-rw-r--r-- | docs/examples/certinfo.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/docs/examples/certinfo.c b/docs/examples/certinfo.c new file mode 100644 index 000000000..ffcec6356 --- /dev/null +++ b/docs/examples/certinfo.c @@ -0,0 +1,81 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ +#include <stdio.h> + +#include <curl/curl.h> + +static size_t wrfu(void *ptr, size_t size, size_t nmemb, void *stream) +{ + (void)stream; + (void)ptr; + return size * nmemb; +} + +int main(void) +{ + CURL *curl; + CURLcode res; + + curl_global_init(CURL_GLOBAL_DEFAULT); + + curl = curl_easy_init(); + if(curl) { + curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/"); + + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, wrfu); + + curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); + curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); + + curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L); + curl_easy_setopt(curl, CURLOPT_CERTINFO, 1L); + + res = curl_easy_perform(curl); + + if(!res) { + struct curl_certinfo *ci = NULL; + + res = curl_easy_getinfo(curl, CURLINFO_CERTINFO, &ci); + + if(!res && ci) { + int i; + 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); + } + + curl_global_cleanup(); + + return 0; +} |