Allow Couchbase SSL to be enabled without custom trust material

Closes gh-35147
This commit is contained in:
Scott Frederick 2023-04-24 14:51:58 -05:00
parent 1d44b45b5d
commit ff35cc80d7
2 changed files with 18 additions and 3 deletions

View File

@ -125,8 +125,14 @@ public class CouchbaseAutoConfiguration {
}
private void configureSsl(Builder builder, SslBundles sslBundles) {
builder.securityConfig((config) -> config.enableTls(true)
.trustManagerFactory(getTrustManagerFactory(this.properties.getEnv().getSsl(), sslBundles)));
builder.securityConfig((config) -> {
config.enableTls(true);
TrustManagerFactory trustManagerFactory = getTrustManagerFactory(this.properties.getEnv().getSsl(),
sslBundles);
if (trustManagerFactory != null) {
config.trustManagerFactory(trustManagerFactory);
}
});
}
@SuppressWarnings("removal")
@ -138,7 +144,7 @@ public class CouchbaseAutoConfiguration {
SslBundle bundle = sslBundles.getBundle(ssl.getBundle());
return bundle.getManagers().getTrustManagerFactory();
}
throw new IllegalStateException("A key store or bundle must be configured when SSL is enabled");
return null;
}
@SuppressWarnings("removal")

View File

@ -180,6 +180,15 @@ class CouchbaseAutoConfigurationTests {
"spring.couchbase.env.timeouts.analytics=6s", "spring.couchbase.env.timeouts.management=7s");
}
@Test
void enableSsl() {
testClusterEnvironment((env) -> {
SecurityConfig securityConfig = env.securityConfig();
assertThat(securityConfig.tlsEnabled()).isTrue();
assertThat(securityConfig.trustManagerFactory()).isNull();
}, "spring.couchbase.env.ssl.enabled=true");
}
@Test
void enableSslWithKeyStore() {
testClusterEnvironment((env) -> {