Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7630581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:08:24+00:00 2026-05-31T06:08:24+00:00

I have an s3 bucket called foo.example.com, which is all CNAMEd correctly. I’m switching

  • 0

I have an s3 bucket called foo.example.com, which is all CNAMEd correctly.

I’m switching to the latest AWS .net SDK.

I wish to generate pre signed url like:

http://foo.example.com/myfile.txt?s3_params_here

Note the vanity cname there.

I have:

string bucketName = "foo.example.com";

AmazonS3Client s3Client = new AmazonS3Client("bar", "xxx",
    new AmazonS3Config
    {
        ServiceURL = bucketName, 
        CommunicationProtocol = Protocol.HTTP
    });


string key = "myfile.txt";


GetPreSignedUrlRequest request = new GetPreSignedUrlRequest()
.WithBucketName(bucketName)
.WithKey(key)
.WithExpires(DateTime.Now.AddMinutes(5))
.WithProtocol(Protocol.HTTP);

string url = s3Client.GetPreSignedURL(request);

the url I get is something like:

http://foo.example.com.foo.example.com/myfile.txt?AWSAccessKeyId=bar&Expires=1331069777&Signature=234KoUUvfE1nCcs2vLj9RQUhqF8%3D

Which is clearly wrong.

I’ve tried a buch of different variations with ServiceURL, bucketname, etc, but nothing seems to work.

I can’t find any good documentation – what is the correct way to do this?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T06:08:25+00:00Added an answer on May 31, 2026 at 6:08 am

    Update [workaround]

    I’ve meanwhile resolved the contradicting test results of mine, which stem from respectively unsystematic testing and URL manipulations. The following workaround does the trick for me (i.e. tested and reproducible), simply starting from your solution:

    string bucketName = "foo.example.com";
    
    // [...]
    
    GetPreSignedUrlRequest request = new GetPreSignedUrlRequest()
        .WithBucketName(bucketName)
        .WithKey(key)
        .WithExpires(DateTime.Now.AddMinutes(32))
        .WithProtocol(Protocol.HTTP);
    

    Now this yields the erroneous URL with a duplicate domain name, i.e. http://foo.example.com.foo.example.com/myfile.txt?[...]

    The duplicate can simply be removed though, e.g.:

    string url = s3Client.GetPreSignedURL(request);
    
    // KLUDGE: remove duplicate domain name.
    url = url.Replace(bucketName + "." + bucketName, bucketName);
    

    This yields a proper working pre-signed URL for me (i.e. http://foo.example.com/myfile.txt?[...]) by working around the encountered limitation regarding the desired approach outlined below.

    Justification

    Manipulating the generated URL like so seems odd, but this not having an effect on the query string authentication is in line with how these signatures are created, see Query String Request Authentication Alternative, where you’ll find the pseudo-grammar that illustrates the query string request authentication method:

    StringToSign = HTTP-VERB + "\n" +
        Content-MD5 + "\n" +
        Content-Type + "\n" +
        Expires + "\n" +
        CanonicalizedAmzHeaders +
        CanonicalizedResource;    
    

    That is, the domain name isn’t used for the signature creation at all, rather only information regarding the resource itself; section Example Query String Request Authentication right below the referenced pseudo-grammar fragment illustrates this with an actual resource.

    Assessment

    I don’t know whether there is still a misunderstanding on our part or whether this might just be a bug in the AWS SDK for .NET, see e.g. Why is my S3 pre-signed request invalid when I set a response header override that contains a “+”? for a related bug resolved via a similar workaround as well, which has meanwhile been fixed though; accordingly, this should likely be escalated to the AWS forums and/or support channels to get an appropriate answer or solution.

    Good luck!


    Desired answer [dysfunctional]

    The S3 CNAME handling implies the bucket name already, so all you need to do is removing your bucket name from GetPreSignedUrlRequest, i.e. it should look like so:

    GetPreSignedUrlRequest request = new GetPreSignedUrlRequest()
        .WithKey(key)
        .WithExpires(DateTime.Now.AddMinutes(5))
        .WithProtocol(Protocol.HTTP);
    

    I’ve tested this with a bucket of mine and it works as expected like so.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Flex 3 SWF in one Amazon S3 bucket, which dynamically loads
I've got about 200k images in a bucket. They all have expires headers of
So I have a bucket set up on Amazon S3, which is configured as
I have an S3 Bucket that holds static content for all my clients in
LINQ library in .NET framework does have a very useful function called GroupBy ,
I have a private bucket that stores full sized images for clients, all thumbnails
I have a fixed size array (example: struct bucket[DATASIZE] ) where at the very
Here goes: I have a AWS S3 bucket with a folder and a mobile
How to get images/videos from Amazon Aws Bucket?? I have addedv some images &
Google app engine task queues have configuration as (example) <queue> <name>mail-queue</name> <rate>5/m</rate> <bucket-size>10</bucket-size> </queue>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.