http: improve AWS HTTP v4 Signature auth

- Add support services without region and service prefixes in
the URL endpoint (ex. Min.IO, GCP, Yandex Cloud, Mail.Ru Cloud Solutions, etc)
by providing region and service parameters via aws-sigv4 option.
- Add [:region[:service]] suffix to aws-sigv4 option;
- Fix memory allocation errors.
- Refactor memory management.
- Use Curl_http_method instead() STRING_CUSTOMREQUEST.
- Refactor canonical headers generating.
- Remove repeated sha256_to_hex() usage.
- Add some docs fixes.
- Add some codestyle fixes.
- Add overloaded strndup() for debug - curl_dbg_strndup().
- Update tests.

Closes #6524
This commit is contained in:
Dmitry Wagin 2021-01-25 17:02:09 +03:00 committed by Daniel Stenberg
parent 3c2210713e
commit 796ce293de
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
21 changed files with 740 additions and 255 deletions

View file

@ -113,7 +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},
{"*V", "aws-sigv4", ARG_STRING},
{"*w", "interface", ARG_STRING},
{"*x", "krb", ARG_STRING},
{"*x", "krb4", ARG_STRING},
@ -806,8 +806,9 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
case 'V': /* --aws-sigv4 */
config->authtype |= CURLAUTH_AWS_SIGV4;
GetStr(&config->aws_sigv4_provider, nextarg);
GetStr(&config->aws_sigv4, nextarg);
break;
case 'v': /* --stderr */
if(strcmp(nextarg, "-")) {
FILE *newfile = fopen(nextarg, FOPEN_WRITETEXT);