Spring Boot application.propertics ? TLS? How connection to CouchBase

premiss :
In a typical Java project, I use the following method to connect to Couchbase, and there are no issues with the configuration regarding the “environment.”

ex:

        private static final String connectionString="couchbases://192.168.11.108";
	private static final String username="xxx...";
	private static final String password="xxx...";
	public static final String bucketName="Analytics";


		Cluster cluster = Cluster.connect(connectionString, 
				ClusterOptions.clusterOptions(username, password)
				.environment(t -> t.securityConfig().enableTls(true)
				.trustManagerFactory(InsecureTrustManagerFactory.INSTANCE)		
				.build()));
                Bucket bucket =cluster.bucket(bucketName);
		Scope scope =bucket.scope("Commerce");
		Collection collection =scope.collection("Test");
		System.out.println("already connection ok..");
		QueryResult queryResult= scope.query("SELECT * from Test");
	        List<JsonObject> jsonObjects= queryResult.rowsAsObject();
		System.out.println(jsonObjects);

Questioning:
So how to set application.properties in Spring Boot?

application.propertics

spring.couchbase.env.timeouts.view=15000
spring.couchbase.env.timeouts.query=15000
spring.couchbase.connection-string=couchbases://192.168.11.108
spring.couchbase.username=xxx..
spring.couchbase.password=xxx...
spring.data.couchbase.bucket-name=Analytics
spring.data.couchbase.auto-index=true
spring.couchbase.env.ssl.enabled=true

Some errors will occur with the above settings…
error message:

[com.couchbase.io][SecureConnectionFailedEvent] Detected a TLS problem in the IO layer: javax.net.ssl.SSLHandshakeException: General OpenSslEngine problem, Cause: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Best way is to create a Config class that extends AbstractCouchbaseConfiguration. There are examples in the documentation.

1 Like

Hi @Bowen
I’m having the same problem; have you found a solution?