Hi,
We are migrating our java sdk version from 2.7 to 3.3. And we have couchbase server version 6.5. While using trust certificate, i am getting below error:
2022-08-04T13:55:11.858+05:30 [APP/PROC/WEB/0] [OUT] 2022-Aug-04 08:25:11.857 WARN [cb-events] c.c.endpoint [correlationId : ] - [com.couchbase.endpoint][EndpointConnectionFailedEvent][322ms] Connect attempt 1 failed because of DecoderException: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target {“circuitBreaker”:“DISABLED”,“coreId”:“xxxxx”,“remote”:“xyz.com:11207”,“type”:“KV”}
Below is the complete code I am using to create cluster:
String connectionString = "couchbases://xyz.com";
ClusterEnvironment.Builder envBuilder = ClusterEnvironment.builder();
envBuilder.securityConfig(SecurityConfig.enableNativeTls(false).enableTls(true).trustStore(certPath, keyStorePassword, Optional.of(“JKS”))).ioConfig(IoConfig.enableDnsSrv(true));
ClusterEnvironment env = envBuilder.build();
Cluster cluster = Cluster.connect(connectionString,
ClusterOptions.clusterOptions(bucketName, password).environment(env));
cluster.waitUntilReady(Duration.ofMinutes(1));
try {
System.out.println("Cluster Connection successfull...................");
QueryResult result = cluster.query("select \"Hello world\" as greetings");
System.out.println(result.rowsAsObject());
}catch(Exception ex){
ex.printStackTrace();
}
cluster.disconnect();
env.shutdown();