Added --pubkey option to curl and made --key also work for SCP/SFTP,

plus made --pass work on an SSH private key as well.
This commit is contained in:
Dan Fandrich
2007-03-23 17:59:40 +00:00
parent 0f634a0c89
commit 0043e87014
7 changed files with 53 additions and 13 deletions

View File

@@ -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 <cert[:passwd]> Client certificate file and password (SSL)",
" --cert-type <type> Certificate file type (DER/PEM/ENG) (SSL)",
" --key <key> Private key file name (SSL)",
" --key <key> Private key file name (SSL/SSH)",
" --key-type <type> Private key file type (DER/PEM/ENG) (SSL)",
" --pass <pass> Pass phrase for the private key (SSL)",
" --pass <pass> Pass phrase for the private key (SSL/SSH)",
" --pubkey <key> Public key file name (SSH)",
" --engine <eng> Crypto engine to use (SSL). \"--engine list\" for list",
" --cacert <file> CA certificate to verify peer against (SSL)",
" --capath <directory> 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) {