使用Node.js中的cassandra-driver连接到使用SSL的Cassandra Apache [英] Connect to Cassandra Apache with SSL using cassandra-driver in Node.js
问题描述
我尝试连接到我的Cassandra,但我可能是错误配置。我在localhost上运行它。 Cassandra已经生成认证和附加。在cqlsh中没有标志--ssl的错误。我的片段代码是
I try connect to my Cassandra but I have probably wrongly configured. I run it on localhost. Cassandra has generated certificated and add on. In cqlsh there are no errors with flag --ssl. My fragment code is
var tls = require('tls');
var fs = require('fs');
var options = {
key : fs.readFileSync('client-key.pem'),
cert : fs.readFileSync('client-cert.pem'),
ca : [fs.readFileSync('server-cert.pem')]
};
var client = new cassandra.Client({
contactPoints : ['127.0.0.1'],
authProvider : new cassandra.auth.PlainTextAuthProvider('cassandra', 'cassandra'),
sslOptions : tls.connect(options)
});
我做错了什么?
请帮助!
what I'm doing wrong? Please help!
推荐答案
您不需要指定 tls.connect
,而应该为sslOptions提供选项
。驱动程序用您提供的 sslOptions
调用 tls.connect
。
You should not need to specify tls.connect(options)
rather you should just provide options
for sslOptions. The driver calls tls.connect
with the sslOptions
you provide.
如果您进行此更改并仍然收到错误,您能与我分享他们是什么吗?有许多不同的因素,可以使建立ssl连接失败。
If you make this change and still get errors, can you share with me what they are? There are a lot of different factors that can make establishing an ssl connection fail.
这篇关于使用Node.js中的cassandra-driver连接到使用SSL的Cassandra Apache的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!