couchbase Secure connection to couchbase using java sdk with specific cipher suites and protocols


Example

import com.couchbase.client.core.endpoint.SSLEngineFactory
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment
import com.couchbase.client.java.CouchbaseCluster

object CouchbaseConnection extends  App {
  
//Create default environment object. 
//Set the keystone file path(download keystone from couch base cluster) and keystore password

  val  env = DefaultCouchbaseEnvironment
    .builder()
    .sslEnabled(true)
    .sslKeystoreFile("./conf/couchbase.keystore") //
    .sslKeystorePassword("pR8PHe452353546474778r4reThUfu45678523422")
    .build();

//Get all SSL configuration for the default environment

 val sslEngineFactory = new SSLEngineFactory(env)
  val sslEngine:SSLEngine = sslEngineFactory.get()

//Set the list of enabled ciphers and transport protocols
  sslEngine.setEnabledCipherSuites(Array("TLS_RSA_WITH_AES_256_CBC_SHA"))
  sslEngine.setEnabledProtocols(Array("TLSv1.2"))

  val cluster = CouchbaseCluster.create(env,"127.0.0.1")
  // Open a bucket person
  val bucket = cluster.openBucket("person","test123")
}