Skip to content

Commit 0fb5c3e

Browse files
feat(postgres-cache): map ssl-mode to r2dbc SSLMode (TLS support) (#1)
Consumes CacheProperties.PostgresConfig.sslMode (fireflyframework-cache sibling PR) and applies it via builder.sslMode(SSLMode.fromValue(...)) when set. Blank/ null keeps the driver default (DISABLE) for back-compat. Fixes the Aurora rds.force_ssl rejection of the Postgres session/cache store.
1 parent 4ed65dc commit 0fb5c3e

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/main/java/org/fireflyframework/cache/config/PostgresCacheAutoConfiguration.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import io.r2dbc.pool.ConnectionPoolConfiguration;
2121
import io.r2dbc.postgresql.PostgresqlConnectionConfiguration;
2222
import io.r2dbc.postgresql.PostgresqlConnectionFactory;
23+
import io.r2dbc.postgresql.client.SSLMode;
2324
import io.r2dbc.spi.Connection;
2425
import io.r2dbc.spi.ConnectionFactory;
2526
import lombok.extern.slf4j.Slf4j;
@@ -81,6 +82,14 @@ public ConnectionFactory fireflyCachePostgresConnectionFactory(CacheProperties p
8182
if (cfg.getSchema() != null) {
8283
builder.schema(cfg.getSchema());
8384
}
85+
// TLS: r2dbc-postgresql defaults to DISABLE. Servers that enforce SSL
86+
// (e.g. AWS Aurora with rds.force_ssl) reject unencrypted connections
87+
// ("no pg_hba.conf entry ... no encryption"). Map the configured mode
88+
// when set, so consumers can opt into require/verify-* without a code
89+
// change. Blank/null keeps the driver default (disable) for back-compat.
90+
if (cfg.getSslMode() != null && !cfg.getSslMode().isBlank()) {
91+
builder.sslMode(SSLMode.fromValue(cfg.getSslMode()));
92+
}
8493
if (cfg.getProperties() != null && !cfg.getProperties().isEmpty()) {
8594
Map<String, String> options = new HashMap<>();
8695
for (Map.Entry<String, Object> entry : cfg.getProperties().entrySet()) {

0 commit comments

Comments
 (0)