python - 连接到 RedShift 导致 SSL 错误 : certificate verify failed

标签 python ssl sqlalchemy amazon-redshift psycopg2

我正在尝试通过 Python 2.7/sqlalchemy (1.2.14)/psycopg2 (2.7.6.1) 连接到 RedShift 数据库,但在配置 SSL 属性时遇到问题:

from sqlalchemy import create_engine

connection = create_engine('redshift+psycopg2://(username:password)@(server):5439/(database)?sslmode=verify-full').connect()

sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) SSL error: certificate verify failed

我已经按照亚马逊的说明完成了所有步骤:

  1. Transitioning to ACM Certificates for SSL Connections: Using Other SSL Connection Types

  2. Install and Configure the Amazon Redshift ODBC Driver on Microsoft Windows Operating Systems

所以我现在将最新版本的 redshift-ca-bundle.crt 作为 root.crt 保存到我的 %APPDATA%\postgresql 文件夹中。我还安装了 32 位和 64 位驱动程序,并在成功验证服务器连接的两个 ODBC 管理器工具(32 位和 64 位)中配置了系统 DSN。

要在我的 Python 代码中正确配置 SSL 以便连接,我缺少什么?我知道连接需要 SSL,但不确定如何提供正确的证书。

最佳答案

我能够使用 pypyodbc 和以下连接字符串成功连接(已编辑详细信息):

connection = pypyodbc.connect('Driver={Amazon Redshift (x64)};'
                              'Server=<server>;'
                              'Database=<database>;'
                              'UID=<login>;'
                              'PWD=<password>;'
                              'Port=5439;'
                              'Trusted_Connection=True')

关于python - 连接到 RedShift 导致 SSL 错误 : certificate verify failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53293677/

相关文章:

python - 如何在 OSX 10.8 的用户 bash_profile 中设置多个路径?

python-3.x - 未提取SQLAlchemy OperationalError

python - Flask-SQLAlchemy - 按上次观看排序的系列中第一集未观看的剧集

python,ElementTree,从 xml 文件中添加和删除子元素时出现问题

python - 如何在 python 中的 OpenCv 中添加自定义 Keras 模型

python - 使用Python创建MongoDb数据库

c - 套接字连接返回错误号 ETIMEOUT

php - 如何使用 wsHTTPBinding 创建 php soap wsdl 客户端?

ubuntu - 无法使用 Ubuntu16.04 和 anaconda 安装 gensim

python - 如何设置冲突?