Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add x-amz-content-sha256 to CanonicalHeaders #179

Merged
merged 2 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion common/etc/nginx/include/awssig4.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const mod_hmac = require('crypto');
* Constant defining the headers being signed.
* @type {string}
*/
const DEFAULT_SIGNED_HEADERS = 'host;x-amz-date';
const DEFAULT_SIGNED_HEADERS = 'host;x-amz-content-sha256;x-amz-date';

/**
* Create HTTP Authorization header for authenticating with an AWS compatible
Expand Down Expand Up @@ -76,6 +76,7 @@ function _buildCanonicalRequest(r,
method, uri, queryParams, host, amzDatetime, sessionToken) {
const payloadHash = awsHeaderPayloadHash(r);
let canonicalHeaders = 'host:' + host + '\n' +
'x-amz-content-sha256:' + payloadHash + '\n' +
'x-amz-date:' + amzDatetime + '\n';

if (sessionToken && sessionToken.length > 0) {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/awssig4_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function _runSignatureV4(r) {
const canonicalRequest = awssig4._buildCanonicalRequest(r,
r.method, req.uri, req.queryParams, req.host, amzDatetime, creds.sessionToken);

var expected = '600721cacc21e3de14416de7517868381831f4709e5c5663bbf2b738e4d5abe4';
var expected = 'cf4dd9e1d28c74e2284f938011efc8230d0c20704f56f67e4a3bfc2212026bec';
var signature = awssig4._buildSignatureV4(r,
amzDatetime, eightDigitDate, creds, region, service, canonicalRequest);

Expand Down