Skip to content

Commit 9dff92c

Browse files
govi20mp911de
authored andcommitted
Consider disabled SSL flag in ConnectionFactoryOptions
[resolves #453][#460]
1 parent 85673c6 commit 9dff92c

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
@@ -274,7 +274,12 @@ private static PostgresqlConnectionConfiguration.Builder fromConnectionFactoryOp
274274

275275
private static void setupSsl(PostgresqlConnectionConfiguration.Builder builder, OptionMapper mapper) {
276276

277-
mapper.from(SSL).to(builder::enableSsl);
277+
mapper.from(SSL).map(OptionMapper::toBoolean).to(enableSsl -> {
278+
if(enableSsl) {
279+
builder.enableSsl();
280+
}
281+
});
282+
278283
mapper.from(SSL_MODE).map(it -> {
279284

280285
if (it instanceof String) {

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

+16-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,22 @@ void supportsWithoutUser() {
143143
}
144144

145145
@Test
146-
void supportsSsl() {
146+
void disableSsl() {
147+
PostgresqlConnectionFactory factory = this.provider.create(builder()
148+
.option(DRIVER, POSTGRESQL_DRIVER)
149+
.option(HOST, "test-host")
150+
.option(PASSWORD, "test-password")
151+
.option(USER, "test-user")
152+
.option(SSL, false)
153+
.build());
154+
155+
SSLConfig sslConfig = factory.getConfiguration().getSslConfig();
156+
157+
assertThat(sslConfig.getSslMode()).isEqualTo(SSLMode.DISABLE);
158+
}
159+
160+
@Test
161+
void enableSsl() {
147162
PostgresqlConnectionFactory factory = this.provider.create(builder()
148163
.option(DRIVER, POSTGRESQL_DRIVER)
149164
.option(HOST, "test-host")

0 commit comments

Comments
 (0)