HI i have installed Cassandra 1.2.18 in my local and trying to setup secure connection but getting the below exception in the server. Here is My Java class, Cassandra configuration and the stack trace. I am really stuck with this issue kindly help.
I am using IBM jdk 1.6.
Java Class
public class CassandraClientDatastax {
private Cluster cluster;
private Session session;
public void connect(String node) throws Exception {
SSLContext context =
getSSLContext("client-truststore.jks", "cassandrapw",
"client-keystore.jks", "cassandrapw");
String[] cipherSuites = {
"TLS_RSA_WITH_NULL_SHA256","SSL_RSA_WITH_NULL_MD5","SSL_RSA_WITH_NULL_SHA","TLS_RSA_WITH_AES_128_CBC_SHA"
};
System.out.println("Building cluster ************* ");
cluster =
Cluster.builder().addContactPoints("localhost")
.withPort(9042)
.withSSL(new SSLOptions(context, cipherSuites))
.build();
}
private SSLContext getSSLContext(String truststorePath, String truststorePassword, String keystorePath,
String keystorePassword) throws Exception
{
FileInputStream tsf = new FileInputStream(Thread.currentThread().getContextClassLoader().getResource((truststorePath)).getPath());
FileInputStream ksf = new FileInputStream(Thread.currentThread().getContextClassLoader().getResource((keystorePath)).getPath());
/*InputStream tsf = Thread.currentThread().getContextClassLoader().getResource((truststorePath));
InputStream ksf = Thread.currentThread().getContextClassLoader().getResource((keystorePath));*/
SSLContext ctx = SSLContext.getInstance("TLS");
KeyStore ts = KeyStore.getInstance("JKS");
ts.load(tsf, truststorePassword.toCharArray());
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(ts);
KeyStore ks = KeyStore.getInstance("JKS");
ks.load(ksf, keystorePassword.toCharArray());
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(ks, keystorePassword.toCharArray());
ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), new SecureRandom());
System.out.println("SSL Context Build Done ...................");
return ctx;
}
}
Cassandra Configuration :
client_encryption_options:
enabled: true
keystore: C:/Dev/apache-cassandra-1.2.18/conf/client-keystore.jks
keystore_password: cassandrapw
require_client_auth: true
# Set trustore and truststore_password if require_client_auth is true
truststore: C:/Dev/apache-cassandra-1.2.18/conf/client-truststore.jks
truststore_password: cassandrapw
# More advanced defaults below:
#protocol: TLS
# algorithm: SunX509
# store_type: JKS
# cipher_suites: [TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA]
cipher_suites: [TLS_RSA_WITH_NULL_SHA256,SSL_RSA_WITH_NULL_MD5,SSL_RSA_WITH_NULL_SHA,TLS_RSA_WITH_AES_128_CBC_SHA]
I am getting the below exception
ERROR 15:34:48,551 Unexpected exception during request
javax.net.ssl.SSLHandshakeException: no cipher suites in common
at sun.security.ssl.Handshaker.checkThrown(Handshaker.java:1290)
at sun.security.ssl.SSLEngineImpl.checkTaskThrown(SSLEngineImpl.java:513)
at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:790)
at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:758)