Skip to content

Signature errors #111

@wvmarle

Description

@wvmarle

This issue stems from #91, I think it's better to start a new thread.

In short: when attempting to do parallel uploads, the threads die one by one with a SignatureError. I'm trying to figure out where this problem originates, but haven't got far yet. It's getting late, so I'm calling it a night, hereby the status. Maybe someone can pick it up from here.

I have filtered bits and pieces of a test upload with eight sessions (guaranteed to trigger the issue), and here are what I think are the important snippets from my log.

Note: this uses a slightly changed version of boto to not log the payload (the 1 MB data chunks) in the log file, and also in glacier-cmd I have enabled boto's debug logging. That's normally switched off due to the payload logging... (details see discussion at #90 (comment)).

SHA256 hash of a part of a test archive: d9eee35c8b9a29e1590802e04948db300a2c601ce46f7a07797f1a5d6a0166b1
At 22:43:12 request is created correctly:

Nov 12 23:43:12 DEBUG    glacier-cmd CanonicalRequest:
PUT
/-/vaults/Test/multipart-uploads/a3I3N9Et0D0-nX_ZQJjeKqUCT_8ovXDytQkET3osBO86RCBb9VJpTIALi5pCNta_dZa2boO9jdfOYmg1MoD1xRpjVlB2

host:glacier.us-east-1.amazonaws.com
x-amz-content-sha256:d9eee35c8b9a29e1590802e04948db300a2c601ce46f7a07797f1a5d6a0166b1
x-amz-date:20121112T154312Z
x-amz-glacier-version:2012-06-01
x-amz-sha256-tree-hash:d9eee35c8b9a29e1590802e04948db300a2c601ce46f7a07797f1a5d6a0166b1

host;x-amz-content-sha256;x-amz-date;x-amz-glacier-version;x-amz-sha256-tree-hash
d9eee35c8b9a29e1590802e04948db300a2c601ce46f7a07797f1a5d6a0166b1

SHA256 and tree-hash are identical as it's a 1MB chunk. For larger chunks they will be different, and the hash at the end should be the complete payload hash (not the tree hash).

At 22:43:23 an unspecified error is encountered; boto correctly retries this one, and creates a new request. This request however uses a wrong hash for the payload (or maybe the whole payload is wrong this time?).

Nov 12 23:43:22 DEBUG    glacier-cmd encountered error exception, reconnecting
Nov 12 23:43:22 DEBUG    glacier-cmd establishing HTTPS connection: host=glacier.us-east-1.amazonaws.com, kwargs={}
Nov 12 23:43:23 DEBUG    glacier-cmd Token: NoneNov 12 23:43:23 DEBUG    glacier-cmd CanonicalRequest:
PUT
/-/vaults/Test/multipart-uploads/a3I3N9Et0D0-nX_ZQJjeKqUCT_8ovXDytQkET3osBO86RCBb9VJpTIALi5pCNta_dZa2boO9jdfOYmg1MoD1xRpjVlB2

host:glacier.us-east-1.amazonaws.com
x-amz-content-sha256:d9eee35c8b9a29e1590802e04948db300a2c601ce46f7a07797f1a5d6a0166b1
x-amz-date:20121112T154323Z
x-amz-glacier-version:2012-06-01
x-amz-sha256-tree-hash:d9eee35c8b9a29e1590802e04948db300a2c601ce46f7a07797f1a5d6a0166b1



host;x-amz-content-sha256;x-amz-date;x-amz-glacier-version;x-amz-sha256-tree-hash
3a40d65ddc1dd592b3144a9a529723d38aefb87171a25eb8e4ff0acc34de39a5

Not very surprisingly, this results in an error a little later:

Nov 12 23:44:02 ERROR    glacier-cmd ERROR: Expected 204, got (403, code=InvalidSignatureException, message=The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.

The Canonical String for this request should have been
'PUT
/-/vaults/Test/multipart-uploads/a3I3N9Et0D0-nX_ZQJjeKqUCT_8ovXDytQkET3osBO86RCBb9VJpTIALi5pCNta_dZa2boO9jdfOYmg1MoD1xRpjVlB2

host:glacier.us-east-1.amazonaws.com
x-amz-content-sha256:d9eee35c8b9a29e1590802e04948db300a2c601ce46f7a07797f1a5d6a0166b1
x-amz-date:20121112T154323Z
x-amz-glacier-version:2012-06-01
x-amz-sha256-tree-hash:d9eee35c8b9a29e1590802e04948db300a2c601ce46f7a07797f1a5d6a0166b1

host;x-amz-content-sha256;x-amz-date;x-amz-glacier-version;x-amz-sha256-tree-hash
d9eee35c8b9a29e1590802e04948db300a2c601ce46f7a07797f1a5d6a0166b1'

The String-to-Sign should have been
'AWS4-HMAC-SHA256
20121112T154323Z
20121112/us-east-1/glacier/aws4_request
081bc1d5aa3f8587ecd7f986548defadeafe58fc96f9f3d0c30a13ee1327758c

The key issue is of course: why is the payload hash different from the tree hash and the sha256 hash, when regenarating the request?
Note: it is not simply the hash of another block of the file, I checked that. It's a totally new one.

I expect this payload hash is recalculated by boto; for all other requests (e.g. create vault) it has to be calculated too. So likely they simply calculate it.

If so, the next question: why has the payload changed? This is odd, of course.

This is either a bug of Boto (losing part or all of the payload when retrying? threads should be fully separated though) or an issue related to mmap where the mapping is inconsistent for some reason (very unlikely).

Yet Amazon's reply suggests that the data itself is actually sent correctly. They calculate the hashes themselves, too, and the hash values that are returned by Amazon match the local values. I assume at least this are hashes that Amazon calculated using the received data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions