Repository: opensearch-project/opensearch-go (go)

Issue:
[BUG] Invalid Sigv4 on requests without a body using AWS SDK v1
### What is the bug?
Getting Error: status: [403 Forbidden] exit status 1 when connecting to OpenSearch using AWS SDK v1

### How can one reproduce the bug?
The following code gives Error: status: [403 Forbidden]
exit status 1

```
package main

import (
	"context"
	"fmt"
	"os"

	"github.com/aws/aws-sdk-go/aws/session"
	requestsigner "github.com/opensearch-project/opensearch-go/v3/signer/aws"

	"github.com/opensearch-project/opensearch-go/v3"
	"github.com/opensearch-project/opensearch-go/v3/opensearchapi"
)

const IndexName = "go-test-index1"

func main() {
	if err := example(); err != nil {
		fmt.Println(fmt.Sprintf("Error: %s", err))
		os.Exit(1)
	}
}

const endpoint = "endpoint url" // e.g. https://opensearch-domain.region.com

func example() error {
	// Create an AWS request Signer and load AWS configuration using default config folder or env vars.
	// See https://docs.aws.amazon.com/opensearch-service/latest/developerguide/request-signing.html#request-signing-go
	signer, err := requestsigner.NewSignerWithService(
		session.Options{Profile: "default"},
		requestsigner.OpenSearchService, // Use requestsigner.OpenSearchServerless for Amazon OpenSearch Serverless.
	)
	if err != nil {
		return err
	}
	// Create an opensearch client and use the request-signer.
	client, err := opensearchapi.NewClient(
		opensearchapi.Config{
			Client: opensearch.Config{
				Addresses: []string{endpoint},
				Signer:    signer,
			},
		},
	)
	if err != nil {
		return err
	}

	ctx := context.Background()

	ping, err := client.Ping(ctx, nil)
	if err != nil {
		return err
	}

	fmt.Println(ping)

	return nil
}

```

### What is the expected behavior?
Connection should be successful

### What is your host/environment?
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye


### Do you have any screenshots?
![golangawssdkopensearch](https://github.com/opensearch-project/opensearch-go/assets/35212670/eb927f90-9a9b-4df8-9c1c-ca44ca5ac41c)


### Do you have any additional context?
I am able to connect using AWS SDK v1 with the same credentials.


Pull request description:
Fix: empty body SHA is incorrect using AWS SDK v1 signer.
### Description

The empty body SHA is different (incorrect, it's the SHA for "hello") in the SDK v1 code, it should be one of an empty string.

It's correct in V2, https://github.com/opensearch-project/opensearch-go/blob/d38bdc15de7a759e3c1c538d173a63eef45a2dd2/signer/awsv2/sdkv2signer.go#L33C23-L33C87. 

### Issues Resolved

Closes #492.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check [here](https://github.com/opensearch-project/OpenSearch/blob/main/CONTRIBUTING.md#developer-certificate-of-origin).


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a13d0d0..766926b 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 05c3fe8..90abb47 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 {


Test patch:
diff --git a/signer/aws/aws_test.go b/signer/aws/aws_test.go
index fd493f5..3368f57 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) {