I am trying to convert node.js code to python 2.7. I am trying to connect to cassandra database with certificates.this is my node code.
var ssl_options = {
key: fs.readFileSync('./certificates/cassandra/client/user.key.pem') ,
cert: fs.readFileSync('./certificates/cassandra/client/user.cer.pem'),
ca: [ fs.readFileSync('./certificates/cassandra/server/node0.cer.pem'),
fs.readFileSync('./certificates/cassandra/server/node1.cer.pem') ]
};
cassandra_client = new cassandra.Client(
{
contactPoints: utils.CASSANDRA_CONTACT_POINTS,
sslOptions: ssl_options,
policies: {
loadBalancing : loadBalancingPolicy
}
});
Python code:
from cassandra.cluster import Cluster
from cassandra.policies import DCAwareRoundRobinPolicy
f1 = open("user.key.pem","r")
key = f1.read()
f2= open("user.cer","r")
cert = f2.read()
f3 = open("node1.cer.pem","r").read()
f4 = open("node1.cer.pem","r").read()
ca = [f3,f4]
ssl_options = {
"key" : key ,
"cert": cert,
"ca": ca,
};
cluster = Cluster(
['10.0.1.13', '10.0.1.9'],
load_balancing_policy=DCAwareRoundRobinPolicy(local_dc='dc1'),
ssl_options=ssl_options)
I get an error
cassandra.cluster.NoHostAvailable: ('Unable to connect to any servers', {'10.0.1.13:9042': TypeError("wrap_socket() got an unexpected keyword argument 'cert'",), '10.0.1.9:9042': TypeError("wrap_socket() got an unexpected keyword argument 'cert'",)})
Am I doing something wrong while reading the certificates ?