我有信托店和密钥库文件以及与卡桑德拉帐户有关的所有信息。我用来连接到卡桑德拉的应用程序有一个限制)
感谢您的帮助!
instaclustrust在其网站上有一个帖子,该帖子描述了如何通过SSL与Spark连接到Cassandra:instaclustrust spark with SSL配置的Cassandra
在步骤#6中,他们提供了创建Cassandra Connection Factory类的详细信息,该类别具有createSSLOptions
方法,该方法允许指定特定详细信息:
SSLOptions createSSLOPtions (CassandraConnectorConf.CassandraSSLConf conf) throws KeyStoreException, IOException, CertificateException, NoSuchAlgorithmException, KeyManagementException {
if (conf.trustStorePath().isEmpty()) {
return null;
}
try (InputStream trustStore = this.getClass().getClassLoader().getResourceAsStream(conf.trustStorePath().get())) {
KeyStore keyStore = KeyStore.getInstance(conf.trustStoreType());
keyStore.load(trustStore, conf.trustStorePassword().isDefined() ? conf.trustStorePassword().get().toCharArray() : null);
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(keyStore);
SSLContext context = SSLContext.getInstance(conf.protocol());
context.init(null, tmf.getTrustManagers(), new SecureRandom());
ClassTag<String> tag = scala.reflect.ClassTag$.MODULE$.apply(String.class);
return JdkSSLOptions.builder()
.withSSLContext(context)
.withCipherSuites((String[]) conf.enabledAlgorithms().toArray(tag)).build();
}
}
然后,他们调用该方法对其连接构建器对象进行修饰:
if (conf.cassandraSSLConf().enabled()) {
SSLOptions options = createSSLOPtions(conf.cassandraSSLConf());
if (null != options) {
builder = builder.withSSL(options);
} else {
builder = builder.withSSL();
}
}
return builder;
查看他们的网站,看看是否可以增加它以满足您的需求。