Problems to validate signature

Hi everybody,

I’m getting some problems and honestly i have no idea if something works wrong in my code or if it with delivery.

I´ll try explain with max details here, my “figure” code:

        string awsAccessId = "....";
        string awsSecretKey = "....";
        string bucketName = "sentinel-s2-l1c";

        string httpDate = DateTime.Now.ToString("ddd, dd MMM yyyy HH:mm:ss +0000\n");
        string canonicalString = "GET\n"
                                + "\n"
                                + "\n"
                                + "x-amz-date:" + httpDate + "\n"
                                + "/" + bucketName;

        
        Encoding ae = new UTF8Encoding();
        
        HMACSHA1 signature = new HMACSHA1();
        
        signature.Key = ae.GetBytes(awsSecretKey);
        byte[] bytes = ae.GetBytes(canonicalString);
        byte[] moreBytes = signature.ComputeHash(bytes);
        
        string encodedCanonical = Convert.ToBase64String(moreBytes);

        
        HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);//Received by param
        request.Headers.Add("x-amz-date", httpDate);
        request.Headers.Add("Authorization", "AWS " + awsAccessId + ":" + encodedCanonical);
        
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        return  response;            

The return error on my try catch:
The remote server returned an error: (403) Forbidden

Running by CLI, validating if i’m able:
aws s3 cp s3://sentinel-s2-l1c.s3.amazonaws.com/tiles/29/T/PF/2018/8/28/0/B04.jp2 B04.jp2. --region eu-central-1 --request-payer requester -profile MyName

The return is:
Unknown options: -profile, MyName

I just dont understand what are happend here. I’m following the documentation aws:
https://docs.aws.amazon.com/pt_br/AmazonS3/latest/dev/RequesterPaysBuckets.html

So, i will appreciate any help or sugest here.
Thanks

Hi @edcc, for the REST headers, don’t forget to add the requester payer header like in (https://docs.aws.amazon.com/AmazonS3/latest/dev/ObjectsinRequesterPaysBuckets.html).

For the second error you’re running into, you need double dashes like the other flags, but you only had 1.

Hi @jflasher

I’m attaching images here to try explain:
The requester payer header added, but nothing happend different.

Error:

How to know if i really have a problem in my account, i just dont know were is the problem.

After execute CLI with double dashes

Thanks