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 0b18fc9 commit 8927d2a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,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.fromTyped(SSL_CONTEXT_BUILDER_CUSTOMIZER).to(builder::sslContextBuilderCustomizer);
mapper.from(SSL_TUNNEL).map(it -> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,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 8927d2a

Please sign in to comment.