tool: add AWS HTTP v4 Signature support

Signed-off-by: Matthias Gatto <matthias.gatto@outscale.com>
This commit is contained in:
Matthias Gatto 2020-07-09 12:04:55 +02:00 committed by Daniel Stenberg
parent eb69797766
commit 6b27df8269
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
5 changed files with 12 additions and 0 deletions

View File

@ -168,6 +168,8 @@ static void free_config_fields(struct OperationConfig *config)
Curl_safefree(config->ftp_account);
Curl_safefree(config->ftp_alternative_to_user);
Curl_safefree(config->aws_sigv4_provider);
}
void config_free(struct OperationConfig *config)

View File

@ -284,6 +284,7 @@ struct OperationConfig {
0 is valid. default: CURL_HET_DEFAULT. */
bool haproxy_protocol; /* whether to send HAProxy protocol v1 */
bool disallow_username_in_url; /* disallow usernames in URLs */
char *aws_sigv4_provider;
struct GlobalConfig *global;
struct OperationConfig *prev;
struct OperationConfig *next; /* Always last in the struct */

View File

@ -113,6 +113,7 @@ static const struct LongShort aliases[]= {
{"*t", "proxy-ntlm", ARG_BOOL},
{"*u", "crlf", ARG_BOOL},
{"*v", "stderr", ARG_FILENAME},
{"*V", "aws-sigv4", ARG_STRING},
{"*w", "interface", ARG_STRING},
{"*x", "krb", ARG_STRING},
{"*x", "krb4", ARG_STRING},
@ -803,6 +804,10 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
config->crlf = toggle;
break;
case 'V': /* --aws-sigv4 */
config->authtype |= CURLAUTH_AWS_SIGV4;
GetStr(&config->aws_sigv4_provider, nextarg);
break;
case 'v': /* --stderr */
if(strcmp(nextarg, "-")) {
FILE *newfile = fopen(nextarg, FOPEN_WRITETEXT);

View File

@ -817,6 +817,8 @@ static const struct helptxt helptext[] = {
{"-A, --user-agent <name>",
"Send User-Agent <name> to server",
CURLHELP_IMPORTANT | CURLHELP_HTTP},
{" --aws-sigv4 <provider1[:provider2]>",
"Use HTTP AWS V4 Signature", CURLHELP_HTTP},
{"-v, --verbose",
"Make the operation more talkative",
CURLHELP_IMPORTANT | CURLHELP_VERBOSE},

View File

@ -1661,6 +1661,8 @@ static CURLcode single_transfer(struct GlobalConfig *global,
my_setopt_str(curl, CURLOPT_SSLKEYTYPE, config->key_type);
my_setopt_str(curl, CURLOPT_PROXY_SSLKEYTYPE,
config->proxy_key_type);
my_setopt_str(curl, CURLOPT_AWS_SIGV4,
config->aws_sigv4_provider);
if(config->insecure_ok) {
my_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);