Question

S3 CDN endpoint does not seem to work with Presigned-URL generated from application code

I have two endpoints to that generates presigned-urls to put image to S3 and get image from it and everything worked just fine. However, recently I changed the url to the CDN url and nothing has been working. I always get “SignatureDoesNotMatch” error in the response message. I did not change anything other than changing the original endpoint to the CDN endpoint

This works: https://<my bucket name>.sgp1.digitaloceanspaces.com/image/e5acd8e0-abd4-4a99-8035-0c02726ca3fd.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=DO8016JJF4Z8QE87D2DM%2F20250306%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250306T061946Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=d35bf14de0e83993f7cf00f9daa27158590388eaf9ba02f0e8980689abd57163

This does not work: https://<my bucket name>.sgp1.cdn.digitaloceanspaces.com/image/e5acd8e0-abd4-4a99-8035-0c02726ca3fd.png?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=DO8016JJF4Z8QE87D2DM%2F20250306%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250306T062027Z&X-Amz-Expires=86400&X-Amz-SignedHeaders=host&X-Amz-Signature=7db459a5b4b764cb2689caceb84b15d6480d09eb71ba05a6a46af461be008797

Error message:

<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
<Resource>panglot-media/image/6b2d0768-de52-4936-9c23-eb6855437b6e</Resource>
<RequestId>not available</RequestId>

</Error>

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

alexdo
Site Moderator
Site Moderator badge
March 7, 2025

Heya, @matthewhuang

If you want to serve images via the CDN without signing mismatches:

  1. Set up a custom domain (CNAME) pointing to your CDN URL.
  2. Use that custom domain in your presigned URLs.

https://docs.digitalocean.com/products/spaces/how-to/customize-cdn-endpoint/

Hope that this helps!

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.