CURLOPT_AWS_SIGV4.3 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. .\" generated by cd2nroff 0.1 from CURLOPT_AWS_SIGV4.md
  2. .TH CURLOPT_AWS_SIGV4 3 "2025-01-17" libcurl
  3. .SH NAME
  4. CURLOPT_AWS_SIGV4 \- V4 signature
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_AWS_SIGV4, char *param);
  9. .fi
  10. .SH DESCRIPTION
  11. Provides AWS V4 signature authentication on HTTP(S) header.
  12. Pass a char pointer that is the collection of specific arguments are used for
  13. creating outgoing authentication headers. The format of the \fIparam\fP option
  14. is:
  15. .IP provider1[:provider2[:region[:service]]]
  16. .IP "provider1, provider2"
  17. The providers arguments are used for generating some authentication parameters
  18. such as "Algorithm", "date", "request type" and "signed headers".
  19. .IP region
  20. The argument is a geographic area of a resources collection.
  21. It is extracted from the hostname specified in the URL if omitted.
  22. .IP service
  23. The argument is a function provided by a cloud. It is extracted from the
  24. hostname specified in the URL if omitted.
  25. .PP
  26. NOTE: This call set \fICURLOPT_HTTPAUTH(3)\fP to CURLAUTH_AWS_SIGV4. Calling
  27. \fICURLOPT_HTTPAUTH(3)\fP with CURLAUTH_AWS_SIGV4 is the same as calling this with
  28. \fB"aws:amz"\fP in parameter.
  29. Example with "Test:Try", when curl uses the algorithm, it generates
  30. \fB"TEST\-HMAC\-SHA256"\fP for "Algorithm", \fB"x\-try\-date"\fP and \fB"X\-Try\-Date"\fP
  31. for "date", \fB"test4_request"\fP for "request type",
  32. \fB"SignedHeaders=content\-type;host;x\-try\-date"\fP for "signed headers"
  33. If you use just "test", instead of "test:try", test is used for every
  34. generated string.
  35. Setting \fICURLOPT_HTTPAUTH(3)\fP with the CURLAUTH_AWS_SIGV4 bit set is the same as
  36. setting this option with a \fB"aws:amz"\fP parameter.
  37. .SH DEFAULT
  38. NULL
  39. .SH PROTOCOLS
  40. This functionality affects http only
  41. .SH EXAMPLE
  42. .nf
  43. int main(void)
  44. {
  45. CURL *curl = curl_easy_init();
  46. if(curl) {
  47. curl_easy_setopt(curl, CURLOPT_URL,
  48. "https://service.region.example.com/uri");
  49. curl_easy_setopt(curl, CURLOPT_AWS_SIGV4, "provider1:provider2");
  50. /* service and region can also be set in CURLOPT_AWS_SIGV4 */
  51. curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/uri");
  52. curl_easy_setopt(curl, CURLOPT_AWS_SIGV4,
  53. "provider1:provider2:region:service");
  54. curl_easy_setopt(curl, CURLOPT_USERPWD, "MY_ACCESS_KEY:MY_SECRET_KEY");
  55. curl_easy_perform(curl);
  56. }
  57. }
  58. .fi
  59. .SH NOTES
  60. This option overrides the other auth types you might have set in
  61. \fICURLOPT_HTTPAUTH(3)\fP which should be highlighted as this makes this auth method
  62. special. This method cannot be combined with other auth types.
  63. A sha256 checksum of the request payload is used as input to the signature
  64. calculation. For POST requests, this is a checksum of the provided
  65. \fICURLOPT_POSTFIELDS(3)\fP. Otherwise, it is the checksum of an empty buffer. For
  66. requests like PUT, you can provide your own checksum in an HTTP header named
  67. \fBx\-provider2\-content\-sha256\fP.
  68. For \fBaws:s3\fP, a \fBx\-amz\-content\-sha256\fP header is added to every request if
  69. not already present. For s3 requests with unknown payload, this header takes
  70. the special value "UNSIGNED\-PAYLOAD".
  71. .SH AVAILABILITY
  72. Added in curl 7.75.0
  73. .SH RETURN VALUE
  74. Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
  75. .SH SEE ALSO
  76. .BR CURLOPT_HEADEROPT (3),
  77. .BR CURLOPT_HTTPAUTH (3),
  78. .BR CURLOPT_HTTPHEADER (3),
  79. .BR CURLOPT_PROXYAUTH (3)