From fbef00aa6244368ccf87d5e15c8c3c5bb186e3ab Mon Sep 17 00:00:00 2001 From: Theo Truong Date: Fri, 20 Jan 2023 17:19:41 -0700 Subject: [PATCH] # Added x-amz-content-sha256 Signed-off-by: Theo Truong --- lib/aws/AwsSigv4Signer.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/aws/AwsSigv4Signer.js b/lib/aws/AwsSigv4Signer.js index 9a7455007..d46ba351d 100644 --- a/lib/aws/AwsSigv4Signer.js +++ b/lib/aws/AwsSigv4Signer.js @@ -13,6 +13,7 @@ const Connection = require('../Connection'); const Transport = require('../Transport'); const aws4 = require('aws4'); const AwsSigv4SignerError = require('./errors'); +const crypto = require('crypto'); const getAwsSDKCredentialsProvider = async () => { // First try V3 @@ -77,13 +78,12 @@ function AwsSigv4Signer(opts = {}) { request.region = opts.region; request.headers = request.headers || {}; request.headers['host'] = request.hostname; - if (opts.service === 'aoss') { - const body = delete request.body; - const signed = aws4.sign(request, credentialsState.credentials); - signed.body = body; - return signed; - } - return aws4.sign(request, credentialsState.credentials); + const signed = aws4.sign(request, credentialsState.credentials); + signed.headers['x-amz-content-sha256'] = crypto + .createHash('sha256') + .update(request.body || '', 'utf8') + .digest('hex'); + return signed; } class AwsSigv4SignerConnection extends Connection {