Every S3 call carries a signature: a 64-character hex string made from your secret key and the request. When it is wrong the server says SignatureDoesNotMatch and tells you nothing else useful. This page builds one signature by hand, with real numbers, so you can see which bytes go into it and what each mistake does.
We use the worked example from the AWS documentation (a ranged GET of <code>/test.txt</code> from <code>examplebucket</code>, dated 2013-05-24, with AWS's public example keys), compute every step in a few lines of Python, and compare with botocore. Both give the documented signature <code>f0e8bdb87c964420e857bd35b5d6ed310bd44f0170aba48dd91039c6036bdb41</code>.
Step 1: the canonical request
Six parts, in this order, joined with newlines:
- the method:
GET(upper case) - the path, already URI-encoded:
/test.txt - the query string, sorted: empty here, so an empty line
- the headers, lower-case names, sorted, each as
name:valueplus a newline, then one more blank line - the list of signed header names:
host;range;x-amz-content-sha256;x-amz-date - the SHA-256 of the body, or the string
UNSIGNED-PAYLOAD. For an empty body it ise3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
SHA-256 of that text is <code>7344ae5b7ee6c3e7e6b0fe0640412a37625d1fbfff95c48bbb2dc43964946972</code>.
Step 2: the string to sign
Algorithm name, the request timestamp, the credential scope (date / region / service / <code>aws4_request</code>) and the hash from step 1.
Step 3: the signing key
Four chained HMAC-SHA256 calls, each keyed with the previous result: start with <code>"AWS4" + secret</code>, then the date, the region, the service and the word <code>aws4_request</code>. For the example secret the result is <code>dbb893acc010964918f1fd433add87c70e8b0db6be30c1fbeafefa5ec6ba8378</code>. The key is tied to one day, one region and one service, so a leaked signing key is limited in scope.
Step 4: the signature
HMAC-SHA256 of the string to sign with that key, in hex: <code>f0e8bdb87c964420e857bd35b5d6ed310bd44f0170aba48dd91039c6036bdb41</code>. It goes into the header:
We ran botocore 1.44.4's <code>S3SigV4Auth</code> on the same request with the clock fixed to 2013-05-24T00:00:00Z. Its Authorization header carried the same SignedHeaders and the same signature, character for character.
Ten ways to get SignatureDoesNotMatch
We changed one thing at a time in the canonical request or the inputs and recomputed. Any change gives a completely different signature, which is what the server sees when your client and its idea of the request disagree:
| One change | First 16 hex of the signature | Matches AWS's? |
|---|---|---|
| none (correct) | f0e8bdb87c964420 | yes |
| headers listed in the wrong order (date before content hash) | 979df24952689ced | no |
| host header in upper case | 46b2b75019d8f4f7 | no |
| one trailing space in the Range value | f52f7d15ee36737c | no |
| no blank line after the headers block | 845e44852fc05af7 | no |
| method written in lower case | 41c3b354355ec6b2 | no |
| range left out of the signed-headers list (but sent) | b2506dbb8b93c74d | no |
| body hash replaced by UNSIGNED-PAYLOAD | 453b26c1b8f3f068 | no |
| region eu-west-1 instead of us-east-1 | 8bdd9c6217292101 | no |
| date one day off in the scope | e681f8aaa18a1e43 | no |
| secret key with a trailing newline (copied from a file) | 06a24f6e5ea950aa | no |
- Header problems are the most common cause in hand-written clients: sort by lower-case name, trim spaces, and sign exactly the headers you send.
- The region in the scope must be the one the service expects.
s3.tport.spaceuses regionauto; sign with that, notus-east-1. - A secret read from a file keeps its newline unless you strip it. It never looks wrong when printed.
S3 specifics
- The path is encoded once. Most AWS services encode the path twice in the canonical request; S3 does not. botocore's S3 signer returns the path untouched. For
/my file.txtthe right canonical path is/my%20file.txt; encoding twice gives/my%2520file.txt, and/café.txtbecomes/caf%25C3%25A9.txtinstead of/caf%C3%A9.txt. Our example path has no special characters, so both ways looked the same. - x-amz-content-sha256 is a required header on S3 and must hold the same value as the last canonical line. Use
UNSIGNED-PAYLOADover HTTPS if you do not want to hash the body first. - Presigned URLs use the same algorithm with the parameters in the query string and
UNSIGNED-PAYLOADas the payload hash.
Related: <a href="https://tport.space/articles/presigned-urls-or-public-files">presigned URLs or public files</a> and <a href="https://tport.space/articles/securing-webhook-upload-drops-s3-presigned-put">presigned PUT URLs with expiry and size limits</a>.
S3-compatible buckets with no egress fees. Signature Version 4 on every request, so any SDK or hand-written client works.
Explore tport.spaceTest record and sources
- Run 2026-11-17 on Windows 11 with Python 3.13 and botocore 1.44.4. Pure computation: no network, no account, no bucket. The example access key and secret are the public ones in the AWS documentation.
- The mistake table is our own recomputation of the same canonical request with one change each; it shows the signature changes, not a server response.
- Source: AWS, Signature Version 4 signing process and the Amazon S3 "Signature Calculations for the Authorization Header" example (GET Object with Range, examplebucket, 20130524, signature f0e8bdb8...).