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

Signature invalid if metadata contains two consecutive spaces #277

Closed
WolfspiritM opened this issue Jan 18, 2019 · 1 comment · Fixed by #278
Closed

Signature invalid if metadata contains two consecutive spaces #277

WolfspiritM opened this issue Jan 18, 2019 · 1 comment · Fixed by #278

Comments

@WolfspiritM
Copy link
Contributor

WolfspiritM commented Jan 18, 2019

Hi,

When using MetaData that contains two consecutive spaces the signature doesn't match with the calulcated server signature.

var metaData = new Dictionary<string, string>()
{
    {"X-Amz-Meta-Test", "Test  Test"}
};
await minio.PutObjectAsync("bucket",
                           "test",
                           filestream,
                           filestream.Length,
                           "application/octet-stream",
                            metaData);
MinioException: Minio API responded with message=The request signature we calculated does not match the signature you provided. Check your key and signing method

The minio server contains the following go function to create a signature based on signed headers.

// Trim leading and trailing spaces and replace sequential spaces with one space, following Trimall()
// in http://docs.aws.amazon.com/general/latest/gr/sigv4-create-canonical-request.html
func signV4TrimAll(input string) string {
	// Compress adjacent spaces (a space is determined by
	// unicode.IsSpace() internally here) to one space and return
	return strings.Join(strings.Fields(input), " ")
}

The minio-dotnet library however calcucates the siganture without removing additional spaces.

If that is true, then this issue needs to be opened in the other libs aswell as I think at least minio-go and minio-js don't have anything related to trimAll, too.

@WolfspiritM WolfspiritM changed the title Signature invalid if metadata contains two spaces Signature invalid if metadata contains two consecutive spaces Jan 18, 2019
@kannappanr kannappanr added this to the Current milestone Jan 18, 2019
@kannappanr
Copy link
Contributor

@WolfspiritM Thanks for filing this issue. We will test this out and fix it.

poornas added a commit to poornas/minio-dotnet that referenced this issue Jan 18, 2019
S3 Spec requires canonicalized header string to have all extra
spaces trimmed down to a single space. This PR fixes minio#277, where
metadata with extra spaces in the value was causing a signature
verification mismatch.
kannappanr pushed a commit that referenced this issue Jan 24, 2019
S3 Spec requires canonicalized header string to have all extra
spaces trimmed down to a single space. This PR fixes #277, where
metadata with extra spaces in the value was causing a signature
verification mismatch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants