diff --git a/src/main/java/io/r2dbc/postgresql/PostgresqlConnectionFactoryProvider.java b/src/main/java/io/r2dbc/postgresql/PostgresqlConnectionFactoryProvider.java index 8f0dba82..44f0e7c7 100644 --- a/src/main/java/io/r2dbc/postgresql/PostgresqlConnectionFactoryProvider.java +++ b/src/main/java/io/r2dbc/postgresql/PostgresqlConnectionFactoryProvider.java @@ -287,7 +287,12 @@ private static PostgresqlConnectionConfiguration.Builder fromConnectionFactoryOp private static void setupSsl(PostgresqlConnectionConfiguration.Builder builder, OptionMapper mapper) { - mapper.from(SSL).to(builder::enableSsl); + mapper.from(SSL).map(OptionMapper::toBoolean).to(enableSsl -> { + if(enableSsl) { + builder.enableSsl(); + } + }); + mapper.from(SSL_MODE).map(it -> { if (it instanceof String) { diff --git a/src/test/java/io/r2dbc/postgresql/PostgresqlConnectionFactoryProviderUnitTests.java b/src/test/java/io/r2dbc/postgresql/PostgresqlConnectionFactoryProviderUnitTests.java index a5e0ec03..0e35becd 100644 --- a/src/test/java/io/r2dbc/postgresql/PostgresqlConnectionFactoryProviderUnitTests.java +++ b/src/test/java/io/r2dbc/postgresql/PostgresqlConnectionFactoryProviderUnitTests.java @@ -149,7 +149,22 @@ void supportsWithoutUser() { } @Test - void supportsSsl() { + void disableSsl() { + PostgresqlConnectionFactory factory = this.provider.create(builder() + .option(DRIVER, POSTGRESQL_DRIVER) + .option(HOST, "test-host") + .option(PASSWORD, "test-password") + .option(USER, "test-user") + .option(SSL, false) + .build()); + + SSLConfig sslConfig = factory.getConfiguration().getSslConfig(); + + assertThat(sslConfig.getSslMode()).isEqualTo(SSLMode.DISABLE); + } + + @Test + void enableSsl() { PostgresqlConnectionFactory factory = this.provider.create(builder() .option(DRIVER, POSTGRESQL_DRIVER) .option(HOST, "test-host")