I encountered the following error when I updated from Couchbase Java SDK 2.7.11 to 3.2.4.
2022-01-10 15:24:35.406 WARN [servce-name,,,] 1 --- [ cb-events] com.couchbase.endpoint : [com.couchbase.endpoint][EndpointConnectionFailedEvent][4230ms] Connect attempt 19 failed because of DecoderException: javax.net.ssl.SSLHandshakeException: No name matching couchbase found {"circuitBreaker":"DISABLED","coreId":"0x7dd5f40800000001","remote":"couchbase:11207","type":"KV"}
com.couchbase.client.core.deps.io.netty.handler.codec.DecoderException: javax.net.ssl.SSLHandshakeException: No name matching couchbase found
at java.base/java.lang.Thread.run(Thread.java:829) ~[na:na]
Caused by: javax.net.ssl.SSLHandshakeException: No name matching couchbase found
at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131) ~[na:na]
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:349) ~[na:na]
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:292) ~[na:na]
at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:287) ~[na:na]
at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkServerCerts(CertificateMessage.java:1357) ~[na:na]
at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.onConsumeCertificate(CertificateMessage.java:1232) ~[na:na]
at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.consume(CertificateMessage.java:1175) ~[na:na]
at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:392) ~[na:na]
at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:443) ~[na:na]
at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask$DelegatedAction.run(SSLEngineImpl.java:1074) ~[na:na]
at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask$DelegatedAction.run(SSLEngineImpl.java:1061) ~[na:na]
at java.base/java.security.AccessController.doPrivileged(Native Method) ~[na:na]
at java.base/sun.security.ssl.SSLEngineImpl$DelegatedTask.run(SSLEngineImpl.java:1008) ~[na:na]
... 1 common frames omitted
Caused by: java.security.cert.CertificateException: No name matching couchbase found
at java.base/sun.security.util.HostnameChecker.matchDNS(HostnameChecker.java:234) ~[na:na]
at java.base/sun.security.util.HostnameChecker.match(HostnameChecker.java:103) ~[na:na]
at java.base/sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:455) ~[na:na]
at java.base/sun.security.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:429) ~[na:na]
at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:283) ~[na:na]
at java.base/sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:141) ~[na:na]
at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkServerCerts(CertificateMessage.java:1335) ~[na:na]
... 9 common frames omitted
The update works fine when connecting without TLS
@Bean
public Cluster cluster(CouchbaseProperties properties) {
return Cluster.connect(
properties.getBootstrapHosts().stream().collect(Collectors.joining(",")),
properties.getBucket().getUsername(),
properties.getBucket().getPassword()
);
}
but I get the error when I attempt to connect using a self signed certificate that I created following
@Bean(destroyMethod = "shutdown")
public ClusterEnvironment clusterEnvironment(CouchbaseProperties properties) {
Path tlsKeyStorePath = Paths.get(properties.getTlsKeystore().getLocation());
log.info("Enabling TLS for all client/server couchbase communication using TLS Keystore: {}",
tlsKeyStorePath);
return ClusterEnvironment.builder()
.securityConfig(SecurityConfig
.enableTls(true)
.trustStore(
tlsKeyStorePath,
properties.getTlsKeystore().getPassword(),
Optional.empty()
)
)
.timeoutConfig(TimeoutConfig.builder()
.connectTimeout(properties.getConnectTimeout())
)
.build();
}
@Bean(destroyMethod = "disconnect")
public Cluster cluster(CouchbaseProperties properties, ClusterEnvironment clusterEnvironment) {
// List of cluster nodes, separated by commas
String connectionString = properties.getBootstrapHosts().stream().collect(Collectors.joining(","));
log.info("Connecting to couchbase cluster using connection string: {}", connectionString);
Path tlsKeyStorePath = Paths.get(properties.getTlsKeystore().getLocation());
log.info("Authenticating couchbase connecting using certificate from TLS keystore: {}",
tlsKeyStorePath);
ClusterOptions clusterOptions = ClusterOptions
.clusterOptions(CertificateAuthenticator.fromKeyStore(
tlsKeyStorePath,
properties.getTlsKeystore().getPassword(),
Optional.empty()))
.environment(clusterEnvironment);
return Cluster.connect(connectionString, clusterOptions);
}
Any advice would be apprecated.