cassandra ssl握手异常:没有共同的密码套件

时间:2014-07-16 13:46:04

标签: ssl cassandra

我已经在我的本地安装了Cassandra 1.2.18并试图建立安全连接,但在服务器中获得以下异常。这是My Java类,Cassandra配置和堆栈跟踪。我真的很难受到这个问题的帮助。

我正在使用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配置:

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]

我收到以下异常

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)

0 个答案:

没有答案