From 4fd7abe97f43ae5098298d13f69fd76bb9c2180f Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Wed, 27 Mar 2024 13:38:01 -0400 Subject: [PATCH] Fix: empty body SHA is incorrect. (#496) Signed-off-by: dblock --- CHANGELOG.md | 1 + signer/aws/aws.go | 2 +- signer/aws/aws_test.go | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a13d0d0a9..766926bd8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Deprecated ### Removed ### Fixed +- Fix SigV4 with AWS SDK v1 ([#496](https://github.com/opensearch-project/opensearch-go/pull/496)) ### Security ## [3.0.0] diff --git a/signer/aws/aws.go b/signer/aws/aws.go index 05c3fe840..90abb4725 100644 --- a/signer/aws/aws.go +++ b/signer/aws/aws.go @@ -31,7 +31,7 @@ const OpenSearchService = "es" const OpenSearchServerless = "aoss" //nolint:gosec // static empty Body -const emptyBodySHA256 = "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824" +const emptyBodySHA256 = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" // Signer is an interface that will implement opensearchtransport.Signer type Signer struct { diff --git a/signer/aws/aws_test.go b/signer/aws/aws_test.go index fd493f54c..3368f576b 100644 --- a/signer/aws/aws_test.go +++ b/signer/aws/aws_test.go @@ -65,7 +65,7 @@ func TestV4Signer(t *testing.T) { q := req.Header assert.NotEmpty(t, q.Get("Authorization")) assert.NotEmpty(t, q.Get("X-Amz-Date")) - assert.Equal(t, "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824", q.Get("X-Amz-Content-Sha256")) + assert.Equal(t, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", q.Get("X-Amz-Content-Sha256")) }) t.Run("sign request success with body", func(t *testing.T) {