1
1
/* gpgkeys_curl.c - fetch a key via libcurl
2
* Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
2
* Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
4
4
* This file is part of GnuPG.
104
104
show_help (FILE *fp)
106
fprintf (fp,"-h\thelp\n");
107
fprintf (fp,"-V\tversion\n");
108
fprintf (fp,"-o\toutput to this file\n");
106
fprintf (fp,"-h, --help\thelp\n");
107
fprintf (fp,"-V\t\tmachine readable version\n");
108
fprintf (fp,"--version\thuman readable version\n");
109
fprintf (fp,"-o\t\toutput to this file\n");
117
118
long follow_redirects=5;
118
119
char *proxy=NULL;
119
120
curl_version_info_data *curldata;
121
struct curl_slist *headers=NULL;
123
125
/* Kludge to implement standard GNU options. */
124
126
if (argc > 1 && !strcmp (argv[1], "--version"))
126
fputs ("gpgkeys_curl (GnuPG) " VERSION"\n", stdout);
128
printf ("gpgkeys_curl (GnuPG) %s\n", VERSION);
129
printf ("Uses: %s\n", curl_version());
129
132
else if (argc > 1 && !strcmp (argv[1], "--help"))
287
290
if(follow_redirects)
289
curl_easy_setopt(curl,CURLOPT_FOLLOWLOCATION,1);
292
curl_easy_setopt(curl,CURLOPT_FOLLOWLOCATION,1L);
290
293
if(follow_redirects>0)
291
294
curl_easy_setopt(curl,CURLOPT_MAXREDIRS,follow_redirects);
299
302
fprintf(console,"gpgkeys: curl version = %s\n",curl_version());
300
303
curl_easy_setopt(curl,CURLOPT_STDERR,console);
301
curl_easy_setopt(curl,CURLOPT_VERBOSE,1);
304
curl_easy_setopt(curl,CURLOPT_VERBOSE,1L);
304
curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,opt->flags.check_cert);
307
curl_easy_setopt(curl,CURLOPT_SSL_VERIFYPEER,(long)opt->flags.check_cert);
305
308
curl_easy_setopt(curl,CURLOPT_CAINFO,opt->ca_cert_file);
310
/* Avoid caches to get the most recent copy of the key. This is bug
311
#1061. In pre-curl versions of the code, we didn't do it. Then
312
we did do it (as a curl default) until curl changed the default.
313
Now we're doing it again, but in such a way that changing
314
defaults in the future won't impact us. We set both the Pragma
315
and Cache-Control versions of the header, so we're good with both
317
headers=curl_slist_append(headers,"Pragma: no-cache");
319
headers=curl_slist_append(headers,"Cache-Control: no-cache");
323
fprintf(console,"gpgkeys: out of memory when building HTTP headers\n");
324
ret=KEYSERVER_NO_MEMORY;
328
curl_easy_setopt(curl,CURLOPT_HTTPHEADER,headers);
308
331
curl_easy_setopt(curl,CURLOPT_PROXY,proxy);