Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用Psycopg2与红移的SSL连接_Python_Ssl_Ssl Certificate_Amazon Redshift_Psycopg2 - Fatal编程技术网

Python 使用Psycopg2与红移的SSL连接

Python 使用Psycopg2与红移的SSL连接,python,ssl,ssl-certificate,amazon-redshift,psycopg2,Python,Ssl,Ssl Certificate,Amazon Redshift,Psycopg2,我正在尝试通过SSL连接到AWS红移服务器。我使用python中的psycopg2库来建立连接,并在连接行中将sslmode='require'用作参数。不幸的是,我得到了这个错误: sslmode value "require" invalid when SSL support is not compiled in 我阅读了许多其他类似的PostgreSQL案例,其中提到了PostgeSQL版本存在的问题,但我没有找到任何使用Psycopg2的红移解决方案。我需要为红移安装任何特定的SSL证

我正在尝试通过SSL连接到AWS红移服务器。我使用python中的psycopg2库来建立连接,并在连接行中将
sslmode='require'
用作参数。不幸的是,我得到了这个错误:

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

我阅读了许多其他类似的PostgreSQL案例,其中提到了PostgeSQL版本存在的问题,但我没有找到任何使用Psycopg2的红移解决方案。我需要为红移安装任何特定的SSL证书吗?如果是,如何使用Psycopg2?任何帮助都将不胜感激。

您的群集是否已启用SSL连接?您的URL本身将包含SSL信息。您可以在代码中使用相同的代码。

这对我很有用:

有同样的错误,这是因为我使用的是Anaconda版本的psycopg2。为了修复它,我从这里改编了维克多夫的解决方案并运行:

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