简体   繁体   English

使用Psycopg2与Redshift的SSL连接

[英]SSL connection to Redshift using Psycopg2

I am trying to connect to a AWS Redshift server via SSL. 我正在尝试通过SSL连接到AWS Redshift服务器。 I am using psycopg2 library in python to establish the connection and used sslmode='require' as a parameter in the connect line. 我在python中使用psycopg2库来建立连接,并使用sslmode='require'作为连接行中的参数。 Unfortunately i got this error: 不幸的是我收到了这个错误

sslmode value "require" invalid when SSL support is not compiled in

I read many other similar cases for PostgreSQL which mention the problem exists with the PostgeSQL version, but i didn't find any solutions for Redshift using Psycopg2. 我为PostgreSQL读了很多其他类似的案例,提到了PostgeSQL版本存在的问题,但我没有找到任何使用Psycopg2的Redshift解决方案。 Do i need to install any specific SSL certificate for Redshift? 我是否需要为Redshift安装任何特定的SSL证书? If yes, how do i do it with Psycopg2? 如果是,我如何用Psycopg2做到这一点? Any help will be appreciated. 任何帮助将不胜感激。

This worked for me: https://stackoverflow.com/a/36489939/101266 这对我有用https//stackoverflow.com/a/36489939/101266

had this same error, which turned out to be because I was using the Anaconda version of psycopg2. 有这个错误,原来是因为我使用的是anaconda版本的psycopg2。 To fix it, I had adapt VictorF's solution from here and run: 为了解决这个问题,我从这里开始调整VictorF的解决方案并运行:

conda uninstall psycopg2
sudo ln -s /Users/YOURUSERNAME/anaconda/lib/libssl.1.0.0.dylib /usr/local/lib
sudo ln -s /Users/YOURUSERNAME/anaconda/lib/libcrypto.1.0.0.dylib /usr/local/lib
pip install psycopg2

Is your cluster enabled for SSL connections? 您的群集是否已启用SSL连接? Your URL itself will have the SSL info. 您的URL本身将具有SSL信息。 and you can use the same in your code. 并且您可以在代码中使用相同的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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