1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 16:18:48 -05:00

Added cacert and filetime support

This commit is contained in:
Daniel Stenberg 2000-11-22 13:51:11 +00:00
parent b5739b3a97
commit d419d975b3

View File

@ -109,6 +109,7 @@ typedef enum {
/* Just a set of bits */ /* Just a set of bits */
#define CONF_DEFAULT 0 #define CONF_DEFAULT 0
#define CONF_USEREMOTETIME (1<<0) /* set the remote time on the local file */
#define CONF_AUTO_REFERER (1<<4) /* the automatic referer-system please! */ #define CONF_AUTO_REFERER (1<<4) /* the automatic referer-system please! */
#define CONF_VERBOSE (1<<5) /* talk a lot */ #define CONF_VERBOSE (1<<5) /* talk a lot */
#define CONF_HEADER (1<<8) /* throw the header out too */ #define CONF_HEADER (1<<8) /* throw the header out too */
@ -252,6 +253,7 @@ static void help(void)
" -D/--dump-header <file> Write the headers to this file\n" " -D/--dump-header <file> Write the headers to this file\n"
" -e/--referer Referer page (H)\n" " -e/--referer Referer page (H)\n"
" -E/--cert <cert:passwd> Specifies your certificate file and password (HTTPS)\n" " -E/--cert <cert:passwd> Specifies your certificate file and password (HTTPS)\n"
" --cacert <file> CA certifciate to verify peer against (HTTPS)\n"
" -f/--fail Fail silently (no output at all) on errors (H)\n" " -f/--fail Fail silently (no output at all) on errors (H)\n"
" -F/--form <name=content> Specify HTTP POST data (H)\n" " -F/--form <name=content> Specify HTTP POST data (H)\n"
@ -332,6 +334,7 @@ struct Configurable {
long conf; long conf;
char *url; char *url;
char *cert; char *cert;
char *cacert;
char *cert_passwd; char *cert_passwd;
bool crlf; bool crlf;
char *cookiefile; char *cookiefile;
@ -489,6 +492,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
{"D", "dump-header", TRUE}, {"D", "dump-header", TRUE},
{"e", "referer", TRUE}, {"e", "referer", TRUE},
{"E", "cert", TRUE}, {"E", "cert", TRUE},
{"Ea", "cacert", TRUE},
{"f", "fail", FALSE}, {"f", "fail", FALSE},
{"F", "form", TRUE}, {"F", "form", TRUE},
@ -760,7 +764,11 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
} }
break; break;
case 'E': case 'E':
{ if(subletter == 'a') {
/* CA info PEM file */
GetStr(&config->cacert, nextarg);
}
else {
char *ptr = strchr(nextarg, ':'); char *ptr = strchr(nextarg, ':');
if(ptr) { if(ptr) {
/* we have a password too */ /* we have a password too */
@ -1250,44 +1258,46 @@ void progressbarinit(struct ProgressData *bar)
} }
void free_config_fields(struct Configurable *confp) void free_config_fields(struct Configurable *config)
{ {
if(confp->url) if(config->url)
free(confp->url); free(config->url);
if(confp->userpwd) if(config->userpwd)
free(confp->userpwd); free(config->userpwd);
if(confp->postfields) if(config->postfields)
free(confp->postfields); free(config->postfields);
if(confp->proxy) if(config->proxy)
free(confp->proxy); free(config->proxy);
if(confp->proxyuserpwd) if(config->proxyuserpwd)
free(confp->proxyuserpwd); free(config->proxyuserpwd);
if(confp->cookie) if(config->cookie)
free(confp->cookie); free(config->cookie);
if(confp->cookiefile) if(config->cookiefile)
free(confp->cookiefile); free(config->cookiefile);
if(confp->krb4level) if(config->krb4level)
free(confp->krb4level); free(config->krb4level);
if(confp->headerfile) if(config->headerfile)
free(confp->headerfile); free(config->headerfile);
if(confp->outfile) if(config->outfile)
free(confp->outfile); free(config->outfile);
if(confp->ftpport) if(config->ftpport)
free(confp->ftpport); free(config->ftpport);
if(confp->infile) if(config->infile)
free(confp->infile); free(config->infile);
if(confp->range) if(config->range)
free(confp->range); free(config->range);
if(confp->customrequest) if(config->customrequest)
free(confp->customrequest); free(config->customrequest);
if(confp->writeout) if(config->writeout)
free(confp->writeout); free(config->writeout);
if(confp->httppost) if(config->httppost)
curl_formfree(confp->httppost); curl_formfree(config->httppost);
if(config->cacert)
free(config->cacert);
curl_slist_free_all(confp->quote); /* the checks for confp->quote == NULL */ curl_slist_free_all(config->quote); /* checks for config->quote == NULL */
curl_slist_free_all(confp->postquote); /* */ curl_slist_free_all(config->postquote); /* */
curl_slist_free_all(confp->headers); /* */ curl_slist_free_all(config->headers); /* */
} }
@ -1653,6 +1663,19 @@ operate(struct Configurable *config, int argc, char *argv[])
curl_easy_setopt(curl, CURLOPT_HTTPPOST, config->httppost); curl_easy_setopt(curl, CURLOPT_HTTPPOST, config->httppost);
curl_easy_setopt(curl, CURLOPT_SSLCERT, config->cert); curl_easy_setopt(curl, CURLOPT_SSLCERT, config->cert);
curl_easy_setopt(curl, CURLOPT_SSLCERTPASSWD, config->cert_passwd); curl_easy_setopt(curl, CURLOPT_SSLCERTPASSWD, config->cert_passwd);
if(config->cacert) {
/* available from libcurl 7.5: */
curl_easy_setopt(curl, CURLOPT_CAINFO, config->cacert);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, TRUE);
}
if(config->conf&(CONF_NOBODY|CONF_USEREMOTETIME)) {
/* no body or use remote time */
/* new in 7.5 */
curl_easy_setopt(curl, CURLOPT_FILETIME, TRUE);
}
curl_easy_setopt(curl, CURLOPT_CRLF, config->crlf); curl_easy_setopt(curl, CURLOPT_CRLF, config->crlf);
curl_easy_setopt(curl, CURLOPT_QUOTE, config->quote); curl_easy_setopt(curl, CURLOPT_QUOTE, config->quote);
curl_easy_setopt(curl, CURLOPT_POSTQUOTE, config->postquote); curl_easy_setopt(curl, CURLOPT_POSTQUOTE, config->postquote);