~ubuntu-branches/ubuntu/vivid/curl/vivid

« back to all changes in this revision

Viewing changes to docs/examples/certinfo.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Schuldei
  • Date: 2009-04-02 23:35:45 UTC
  • mto: (1.2.1 upstream) (3.2.3 sid)
  • mto: This revision was merged to the branch mainline in revision 38.
  • Revision ID: james.westby@ubuntu.com-20090402233545-geixkwhe3izccjt7
Tags: upstream-7.19.4
ImportĀ upstreamĀ versionĀ 7.19.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*****************************************************************************
 
2
 */
 
3
 
 
4
#include <stdio.h>
 
5
 
 
6
#include <curl/curl.h>
 
7
#include <curl/types.h>
 
8
#include <curl/easy.h>
 
9
 
 
10
static size_t wrfu(void *ptr,  size_t  size,  size_t  nmemb,  void *stream)
 
11
{
 
12
  return size * nmemb;
 
13
}
 
14
int main(int argc, char **argv)
 
15
{
 
16
  CURL *curl;
 
17
  CURLcode res;
 
18
 
 
19
  curl_global_init(CURL_GLOBAL_DEFAULT);
 
20
 
 
21
  curl = curl_easy_init();
 
22
  if(curl) {
 
23
    curl_easy_setopt(curl, CURLOPT_URL, "https://www.networking4all.com/");
 
24
 
 
25
    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, wrfu);
 
26
 
 
27
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
 
28
    curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
 
29
 
 
30
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 0L);
 
31
    curl_easy_setopt(curl, CURLOPT_CERTINFO, 1L);
 
32
 
 
33
    res = curl_easy_perform(curl);
 
34
 
 
35
    if(!res) {
 
36
      struct curl_certinfo *ci = NULL;
 
37
 
 
38
      res = curl_easy_getinfo(curl, CURLINFO_CERTINFO, &ci);
 
39
 
 
40
      if(!res && ci) {
 
41
        int i;
 
42
        printf("%d certs!\n", ci->num_of_certs);
 
43
 
 
44
        for(i=0; i<ci->num_of_certs; i++) {
 
45
          struct curl_slist *slist;
 
46
 
 
47
          for(slist = ci->certinfo[i]; slist; slist = slist->next)
 
48
            printf("%s\n", slist->data);
 
49
 
 
50
        }
 
51
      }
 
52
 
 
53
    }
 
54
 
 
55
 
 
56
    curl_easy_cleanup(curl);
 
57
  }
 
58
 
 
59
  curl_global_cleanup();
 
60
 
 
61
  return 0;
 
62
}