我正在尝试连接到公司的MySQL数据库.策略是我只使用SSL连接.
我提供了用户名,CA证书,证书和私钥.
如果我使用HeidiSQL,我可以毫无问题地连接.
但是,我无法使用Python 2.7.11与mysql-connector-python-rf(v2.1.3)进行连接.
这是我的简单连接测试程序:
from __future__ import print_function, division, unicode_literals
import mysql.connector
from mysql.connector.constants import ClientFlag
cnx = mysql.connector.connect(
user='myusername',
host='myserver.example.com',
port=3306,
client_flags=[ClientFlag.SSL],
ssl_ca='/path/to/ca.crt',
ssl_cert='/path/to/user.crt',
ssl_key='/path/to/user.key'
)
cnx.close()
我总是得到这个例外:
mysql.connector.errors.InterfaceError: 2055: Lost connection to MySQL server at
'myserver.example.com:3306', system error: 1 [SSL: SSL_NEGATIVE_LENGTH] dh key too small
(_ssl.c:590)
我试过寻找答案,但除了更改服务器端的设置之外似乎没有解决方案,这简直就是禁止.
我该如何修复和/或解决此问题?
更多信息更新:我正在使用PyCharm 5.0.3在Windows 10上创建我的程序