简体   繁体   中英

Python cassandra driver - SSL: WRONG_VERSION_NUMBER

I'm trying to connect to a cassandra node that has SSL enabled, using the datastax cassandra driver, like this:

from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider 

import ssl
ip = <ip>
ap = PlainTextAuthProvider(username=<username>, password=<password>) 

ssl_options = {
  'ca_certs': <path to PEM file>,
  'ssl_version': ssl.PROTOCOL_TLSv1
  }
cluster = Cluster([ip], auth_provider=ap, ssl_options=ssl_options)
session = cluster.connect() 

I can successfully connect to the node using pycassa , but I was trying to switch to using datastax driver for this.

The above code throws the following exception:

NoHostAvailable: ('Unable to connect to any servers', {<ip>: error(1, u"Tried connecting to [(<ip>, <port>)]. Last error: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:590)")})

I know the server accepts PROTOCOL_TLSv1, since it's the default protocol in pycassa. I don't understand what I'm doing wrong here ...

This error commonly occurs when trying to connect with SSL on a socket that is not negotiating SSL.

Confirm that SSL is enabled in the server, and for the port to which you are connecting. I think this should be evident in the server system log.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM