Skip to content

Commit 5666f22

Browse files
committed
Example removed and doc added
1 parent 26c4892 commit 5666f22

5 files changed

Lines changed: 29 additions & 397 deletions

File tree

docs/modules/postgres.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,32 @@ The test example uses the following NuGet dependencies:
3232

3333
To execute the tests, use the command `dotnet test` from a terminal.
3434

35-
--8<-- "docs/modules/_call_out_test_projects.txt"
35+
## Enable SSL/TLS
36+
37+
The PostgreSQL module supports configuring server-side SSL. Provide paths to your CA certificate, server certificate, and server private key when building the container:
38+
39+
```csharp
40+
var postgreSqlContainer = new PostgreSqlBuilder()
41+
.WithSSLSettings("/path/to/ca_cert.pem",
42+
"/path/to/server.crt",
43+
"/path/to/server.key")
44+
.Build();
45+
await postgreSqlContainer.StartAsync();
46+
```
47+
48+
When connecting with Npgsql during tests, you can require SSL and (optionally) trust the test certificate:
49+
50+
```csharp
51+
var csb = new Npgsql.NpgsqlConnectionStringBuilder(postgreSqlContainer.GetConnectionString())
52+
{
53+
SslMode = Npgsql.SslMode.Require,
54+
// For testing only; prefer proper CA validation in production.
55+
TrustServerCertificate = true
56+
};
57+
await using var connection = new Npgsql.NpgsqlConnection(csb.ConnectionString);
58+
await connection.OpenAsync();
59+
```
60+
61+
For production scenarios, validate the server certificate against a trusted CA instead of using TrustServerCertificate.
62+
63+
--8<-- "docs/modules/_call_out_test_projects.txt"

examples/PostgreSqlSslConfigDemo/PostgreSqlSSLConfigExample.cs

Lines changed: 0 additions & 330 deletions
This file was deleted.

examples/PostgreSqlSslConfigDemo/PostgreSqlSslConfigDemo.csproj

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)