From 0043e870145d167003931cda2fd90b5e13b0b7f8 Mon Sep 17 00:00:00 2001 From: Dan Fandrich Date: Fri, 23 Mar 2007 17:59:40 +0000 Subject: Added --pubkey option to curl and made --key also work for SCP/SFTP, plus made --pass work on an SSH private key as well. --- src/main.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 32bc8a03c..56bc1c7bf 100644 --- a/src/main.c +++ b/src/main.c @@ -389,6 +389,7 @@ struct Configurable { char *key; char *key_type; char *key_passwd; + char *pubkey; char *engine; bool list_engines; bool crlf; @@ -607,9 +608,10 @@ static void help(void) " -e/--referer Referer URL (H)", " -E/--cert Client certificate file and password (SSL)", " --cert-type Certificate file type (DER/PEM/ENG) (SSL)", - " --key Private key file name (SSL)", + " --key Private key file name (SSL/SSH)", " --key-type Private key file type (DER/PEM/ENG) (SSL)", - " --pass Pass phrase for the private key (SSL)", + " --pass Pass phrase for the private key (SSL/SSH)", + " --pubkey Public key file name (SSH)", " --engine Crypto engine to use (SSL). \"--engine list\" for list", " --cacert CA certificate to verify peer against (SSL)", " --capath CA directory (made using c_rehash) to verify", @@ -1505,6 +1507,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */ {"Ee","pass", TRUE}, {"Ef","engine", TRUE}, {"Eg","capath ", TRUE}, + {"Eh","pubkey", TRUE}, {"f", "fail", FALSE}, {"F", "form", TRUE}, {"Fs","form-string", TRUE}, @@ -2111,6 +2114,9 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */ /* CA cert directory */ GetStr(&config->capath, nextarg); break; + case 'h': /* --pubkey public key file */ + GetStr(&config->pubkey, nextarg); + break; default: /* certificate file */ { char *ptr = strchr(nextarg, ':'); @@ -3255,6 +3261,8 @@ static void free_config_fields(struct Configurable *config) free(config->key); if (config->key_type) free(config->key_type); + if (config->pubkey) + free(config->pubkey); if (config->referer) free(config->referer); @@ -4112,6 +4120,10 @@ operate(struct Configurable *config, int argc, char *argv[]) my_setopt(curl, CURLOPT_SSLKEYTYPE, config->key_type); my_setopt(curl, CURLOPT_SSLKEYPASSWD, config->key_passwd); + /* SSH private key uses the same command-line option as SSL private key */ + my_setopt(curl, CURLOPT_SSH_PRIVATE_KEYFILE, config->key); + my_setopt(curl, CURLOPT_SSH_PUBLIC_KEYFILE, config->pubkey); + /* default to strict verifyhost */ my_setopt(curl, CURLOPT_SSL_VERIFYHOST, 2); if(config->cacert || config->capath) { -- cgit v1.2.3