Skip to content

Commit 7b00a2b

Browse files
govi20mp911de
authored andcommitted
Consider disabled SSL flag in ConnectionFactoryOptions
[resolves #453][#460]
1 parent c868d03 commit 7b00a2b

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/main/java/io/r2dbc/postgresql/PostgresqlConnectionFactoryProvider.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,12 @@ private static PostgresqlConnectionConfiguration.Builder fromConnectionFactoryOp
287287

288288
private static void setupSsl(PostgresqlConnectionConfiguration.Builder builder, OptionMapper mapper) {
289289

290-
mapper.from(SSL).to(builder::enableSsl);
290+
mapper.from(SSL).map(OptionMapper::toBoolean).to(enableSsl -> {
291+
if(enableSsl) {
292+
builder.enableSsl();
293+
}
294+
});
295+
291296
mapper.from(SSL_MODE).map(it -> {
292297

293298
if (it instanceof String) {

src/test/java/io/r2dbc/postgresql/PostgresqlConnectionFactoryProviderUnitTests.java

+16-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,22 @@ void supportsWithoutUser() {
149149
}
150150

151151
@Test
152-
void supportsSsl() {
152+
void disableSsl() {
153+
PostgresqlConnectionFactory factory = this.provider.create(builder()
154+
.option(DRIVER, POSTGRESQL_DRIVER)
155+
.option(HOST, "test-host")
156+
.option(PASSWORD, "test-password")
157+
.option(USER, "test-user")
158+
.option(SSL, false)
159+
.build());
160+
161+
SSLConfig sslConfig = factory.getConfiguration().getSslConfig();
162+
163+
assertThat(sslConfig.getSslMode()).isEqualTo(SSLMode.DISABLE);
164+
}
165+
166+
@Test
167+
void enableSsl() {
153168
PostgresqlConnectionFactory factory = this.provider.create(builder()
154169
.option(DRIVER, POSTGRESQL_DRIVER)
155170
.option(HOST, "test-host")

0 commit comments

Comments
 (0)