Skip to content

Commit 085ae0f

Browse files
authored
fix: Add x-amz-content-sha256 to CanonicalHeaders (#179)
1 parent 2134898 commit 085ae0f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

common/etc/nginx/include/awssig4.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const mod_hmac = require('crypto');
2828
* Constant defining the headers being signed.
2929
* @type {string}
3030
*/
31-
const DEFAULT_SIGNED_HEADERS = 'host;x-amz-date';
31+
const DEFAULT_SIGNED_HEADERS = 'host;x-amz-content-sha256;x-amz-date';
3232

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

8182
if (sessionToken && sessionToken.length > 0) {

test/unit/awssig4_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function _runSignatureV4(r) {
7474
const canonicalRequest = awssig4._buildCanonicalRequest(r,
7575
r.method, req.uri, req.queryParams, req.host, amzDatetime, creds.sessionToken);
7676

77-
var expected = '600721cacc21e3de14416de7517868381831f4709e5c5663bbf2b738e4d5abe4';
77+
var expected = 'cf4dd9e1d28c74e2284f938011efc8230d0c20704f56f67e4a3bfc2212026bec';
7878
var signature = awssig4._buildSignatureV4(r,
7979
amzDatetime, eightDigitDate, creds, region, service, canonicalRequest);
8080

0 commit comments

Comments
 (0)