Skip to content

preservePathSeparators breaks sns requests #3486

@eyal-di

Description

@eyal-di

Describe the bug

when using options.httpOptions.preservePathSeparators = true; for enabling '/' dirs in s3, sns requests' signatures become invalid.

Aws::SDKOptions options;
options.httpOptions.preservePathSeparators = true;
Aws::InitAPI(options);
...
sns = Aws::SNS::SNSClient();
Aws::SNS::Model::ListTopicsRequest request;
auto outcome = sns.ListTopics(request); // outcome is no successful
...
s3 = Aws::S3:S3Client();
Aws::S3::Model::PutObjectRequest request;
request.SetBucket(...);
request.SetKey("/" + filename); // for example
request.SetBody(...);
Aws::S3::Model::PutObjectOutcome outcome = s3.PutObject(request); //outcome is successfull

Expected Behavior

sns client should sign requests correctly even preservePathSeparators is turned on.

Current Behavior

when sending an sns request the outcome object holds an error:

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.

Reproduction Steps

int main(){
Aws::SDKOptions options;
options.httpOptions.preservePathSeparators = true;
Aws::InitAPI(options);
sns = Aws::SNS::SNSClient();
Aws::SNS::Model::ListTopicsRequest request;
auto outcome = sns.ListTopics(request); // outcome is not successful
}

Possible Solution

No response

Additional Information/Context

log from the faulty run:
[DEBUG] 2025-07-17 09:18:37.875 AWSAuthV4Signer [140324431722304] Canonical Request String: POST
//

amz-sdk-invocation-id:48927949-CB62-47C5-9874-69E5F944D030
amz-sdk-request:attempt=1
content-length:36
content-type:application/x-www-form-urlencoded
host:sns.us-east-2.amazonaws.com
x-amz-api-version:2010-03-31
x-amz-content-sha256:55e772bd3d832d8507965af84ab07fd17d9be3cbb788151ceb0d7fc2be442a54
x-amz-date:20250717T091837Z

amz-sdk-invocation-id;amz-sdk-request;content-length;content-type;host;x-amz-api-version;x-amz-content-sha256;x-amz-date
55e772bd3d832d8507965af84ab07fd17d9be3cbb788151ceb0d7fc2be442a54
[DEBUG] 2025-07-17 09:18:37.875 AWSAuthV4Signer [140324431722304] Final String to sign: AWS4-HMAC-SHA256
20250717T091837Z
20250717/us-east-2/sns/aws4_request
12b79f8d027d379d3babc90497e0403913ebb39a07fc04f425b67390572354cf
[DEBUG] 2025-07-17 09:18:37.875 AWSAuthV4Signer [140324431722304] Final computed signing hash: 9cdb0a4a2993fe088a0eda5a1d178076eb636d6a63a2a1338cbc4673fae70578


log from the good run(was done using python):
2025-07-16 13:41:36,907 botocore.auth [DEBUG] CanonicalRequest:
POST
/

content-type:application/x-www-form-urlencoded; charset=utf-8
host:sns.us-east-2.amazonaws.com
x-amz-date:20250716T134136Z

content-type;host;x-amz-date
55e772bd3d832d8507965af84ab07fd17d9be3cbb788151ceb0d7fc2be442a54
2025-07-16 13:41:36,907 botocore.auth [DEBUG] StringToSign:
AWS4-HMAC-SHA256
20250716T134136Z
20250716/us-east-2/sns/aws4_request
4905c67cafd5bf347bb199fe2bde38fe21914d3f461232556a1f9e76f6d1b7bb
2025-07-16 13:41:36,907 botocore.auth [DEBUG] Signature:
424ef6fb37ee2af64ce9554cb642d30ed193dafa9b2ab350b0aa7638881e5756

AWS CPP SDK version used

1.11.606

Compiler and Version used

gcc 12

Operating System and version

rocky9 9.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions