1

I am trying to connect to an AWS Redshift database from a lambda function using c#, dotnet core 2.0, and npgsql. I am having difficulty with SSL.

I have created two non-publicly-accessible Redshift databases in a dedicated VPC. The lambda executes in the same VPC. The two databases are identical in every way except that one has the "force SSL" parameter set to true.

Using the following code snippet, I can access the non-SSL database just fine:

 using (var conn = new  NpgsqlConnection ("Host=x; Port=5439; Username=x; 
                Password=x;Database=xxx")
                {
                    Console.WriteLine("Redshift pre-Open!");
                    conn.Open();
                    Console.WriteLine("Redshift: post-Open!");
                    ...
                 }

When I access the SSL database, I get the "missing hba.conf" error message - seems standard, I've seen it before ... When I append to the connection string: "ssl Mode=Require;Server Compatibility Mode=Redshift;Trust Server Certificate=true" the conn.open statement hangs, and the second write statement never shows up in cloudwatch.

And yet ... this connection statement works when accessing the same database thru a rest API and C#/dotnetcore 2 WEBAPI (same runtime environment), with an EC2 instance and load balancer.

A Python lambda connecting to the SSL database, in the same environment - subnets, security groups, lambda triggers, lambda parameters, ... is working just fine.

The csproj references Amazon.Lambda.Core 1.0.0, Amazon.Lambda.Serialization.Json 1.1.0, and Npgsql.EntityFrameworkCore.PostgreSQL 2.0.1.

I'd try Wireshark, maybe, in another environment - but running as a lambda, I'm not sure how best to debug. I've tried many permutations and combinations, and I wouldn't put it past myself to be missing something blindingly obvious, but I absolutely do not see why hangs. Thank you.

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.