Skip to content

bug: Issue with SNS message parsing with C# #11850

@nascosto

Description

@nascosto

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Note: I'm trying to migrate from localstack 2.3.2 to localstack 3.8.1. With 2.3.2, the following worked.

Parsing a message using Amazon.SimpleNotificationService.Util.Message.ParseMessage throws an AmazonClientException("Signing certificate url is not from a recognised source."). Investigating this issue the error is being thrown by this method

private static string ValidateCertUrl(string certUrl)
{
    Uri uri = new Uri(certUrl);
    if (uri.Scheme == "https" && certUrl.EndsWith(".pem", StringComparison.Ordinal) && CertUrlRegex().IsMatch(uri.Host))
    {
	    return certUrl;
    }
    throw new AmazonClientException("Signing certificate url is not from a recognised source.");
}

CertUrlRegex is the following regex: ^sns\\.[a-zA-Z0-9\\-]{3,}\\.amazonaws\\.com(\\.cn)?$

The actual SigningCertURL with localstack 3.8.1 is http://localhost.localstack.cloud:4566/_aws/sns/SimpleNotificationService-6c6f63616c737461636b69736e696365.pem which does not meet the validation requirements here. I think in 2.x it was a dummy value that matched the validation needs above.

I'm wondering if there is any way around this.

Expected Behavior

There is no error when calling ParseMessage.

How are you starting LocalStack?

Custom (please describe below)

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

Testcontainers

Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

string dockerHostUri = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ?
    "npipe://./pipe/docker_engine" :
    "unix:///var/run/docker.sock";
var localStackBuilder = new LocalStackBuilder()
    .WithImage("localstack/localstack:3.8.1")
    .WithCleanUp(true)
    .WithEnvironment("SERVICES", "sns,sqs")
    .WithEnvironment("DOCKER_HOST", dockerHostUri)
    .WithEnvironment("DEBUG", "1")
    .WithPortBinding(4566, 4566);

Environment

- OS: Windows 11
- LocalStack:
  LocalStack version: 3.8.1
  LocalStack Docker image sha:
  LocalStack build date:
  LocalStack build git hash:

Anything else?

AWSSDK code: https://github.com/aws/aws-sdk-net/blob/939ed2c7a124425b40de1de7e1deb277c050e171/sdk/src/Services/SimpleNotificationService/Custom/Util/Message.cs#L56

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions