Skip to content

Commit

Permalink
Consider SSL configuration option value
Browse files Browse the repository at this point in the history
We now enable full SSL only when the SSL configuration option is set to true. Previously, SSL was enabled once the SSL option was present regardless of its value.

[fixes #240]

Signed-off-by: Mark Paluch <mpaluch@vmware.com>
  • Loading branch information
mp911de committed Jan 11, 2022
1 parent 4f9ddc4 commit 137e8c6
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 @@ -161,7 +161,12 @@ public MssqlConnectionFactory create(ConnectionFactoryOptions connectionFactoryO
mapper.from(PORT).map(OptionMapper::toInteger).to(builder::port);
mapper.from(PREFER_CURSORED_EXECUTION).map(OptionMapper::toStringPredicate).to(builder::preferCursoredExecution);
mapper.from(SEND_STRING_PARAMETERS_AS_UNICODE).map(OptionMapper::toBoolean).to(builder::sendStringParametersAsUnicode);
mapper.from(SSL).to(builder::enableSsl);
mapper.from(SSL).map(OptionMapper::toBoolean).to(ssl -> {

if (ssl) {
builder.enableSsl();
}
});
mapper.from(SSL_CONTEXT_BUILDER_CUSTOMIZER).to(builder::sslContextBuilderCustomizer);
mapper.from(SSL_TUNNEL).map(it -> {

Expand All @@ -173,7 +178,6 @@ public MssqlConnectionFactory create(ConnectionFactoryOptions connectionFactoryO
}

return it;

}).to(it -> {

if (it != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,22 @@ void shouldConfigureWithSsl() {
assertThat(configuration.getSslTunnelConfiguration().isSslEnabled()).isFalse();
}

@Test
void shouldConfigureWithoutSsl() {

MssqlConnectionFactory factory = this.provider.create(ConnectionFactoryOptions.builder()
.option(SSL, false)
.option(DRIVER, MSSQL_DRIVER)
.option(HOST, "test-host")
.option(PASSWORD, "test-password")
.option(USER, "test-user")
.build());

ClientConfiguration configuration = factory.getClientConfiguration();

assertThat(configuration.isSslEnabled()).isFalse();
}

@Test
void shouldConfigureWithSslCustomizer() {

Expand Down

0 comments on commit 137e8c6

Please sign in to comment.