Skip to content

Commit

Permalink
Consider disabled SSL flag in ConnectionFactoryOptions
Browse files Browse the repository at this point in the history
[resolves #453][#460]
  • Loading branch information
govi20 authored and mp911de committed Oct 26, 2021
1 parent c868d03 commit 7b00a2b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 7b00a2b

Please sign in to comment.