我正在使用 PyCURL 来测试我们提供的重定向服务 - 用户点击 http://xyz.com/asdf / 并被重定向到 https://a.com,https://b.com 和 https://c.com。
我正在尝试使用 PyCURL 请求 http://xyz.com 并打印出来(但不是 HTTP 请求)字符串“https://{a|b|c}.com”,但只要目标 URL 是 HTTPS 而不是 HTTP,PyCURL.request() 方法就会抛出以下异常:
(35, 'gnutls_handshake()失败:已收到 TLS 致命警报。')
谷歌搜索“pycurl tls error”并没有找到很多结果,除了暗示 Ubuntu 的 PyCURL 使用 GnuTLS 而不是 OpenSSL 的结果。这是导致我的问题的原因吗?如果是这样,如何配置 PyCURL 以使用 OpenSSL?
我的操作系统是 Ubuntu 9.10,Python 2.6,这是我的 PyCURL 版本信息
>>>>> pycurl.version_info()
(3, '7.19.5', 463621, 'x86_64-pc-linux-gnu', 1597, 'GnuTLS/2.8.3', 0, '1.2.3.3' , ('tftp', 'ftp', 'telnet', 'dict', 'ldap', 'ldaps', 'http', '文件', 'https', 'ftps'), 无, 0, '1.15' )
提前致谢!
I'm using PyCURL to test a redirection service we're offering- a user hits http://xyz.com/asdf/ and gets redirected to https://a.com, https://b.com and https://c.com.
I'm trying to use PyCURL to request http://xyz.com, and print out (but not HTTP request) the string "https://{a|b|c}.com", but whenever the destination URL is HTTPS and not HTTP, PyCURL.request() method throws the following exception:
(35, 'gnutls_handshake() failed: A TLS fatal alert has been received.')
Googling for "pycurl tls error" doesn't turn up many results, except one that hints that PyCURL for Ubuntu uses GnuTLS instead of OpenSSL. Is this what's causing my problem? If so, how do I configure PyCURL to use OpenSSL?
My OS is Ubuntu 9.10, Python 2.6, and here's my PyCURL version info
>>> pycurl.version_info()
(3, '7.19.5', 463621, 'x86_64-pc-linux-gnu', 1597, 'GnuTLS/2.8.3', 0, '1.2.3.3', ('tftp', 'ftp', 'telnet', 'dict', 'ldap', 'ldaps', 'http', 'file', 'https', 'ftps'), None, 0, '1.15')
Thanks in advance!
发布评论
评论(2)
我刚刚解决了同样的问题。我不能 100% 确定出了什么问题。
但是我通过 apt-get install python-pycurl 安装了 pycurl ,我认为默认情况下使用 gnutls ,但在我看来它应该是我的系统上的 openssl 。
我通过执行以下操作解决了该问题:
export PYCURL_SSL_LIBRARY=[openssl|gnutls|nss]
(选择 openssl、gnutls 或 nss 3 个之一,不带括号)pip install pycurl --升级
如果您的 pycurl 版本已经是最新版本,请通过执行以下命令
pip uninstall pycurl
将其删除,然后运行上述命令。来源: http://pycurl.sourceforge.net/doc/install.html
I just resolved the same issue. I'm not 100% sure what was wrong.
But I installed pycurl via
apt-get install python-pycurl
which i think by default uses gnutls, but it seemed to me it should be openssl on my system.I resolved it by doing the following:
export PYCURL_SSL_LIBRARY=[openssl|gnutls|nss]
(choose one of the 3, openssl,gnutls or nss, without the brackets)pip install pycurl --upgrade
If your version of pycurl is already at the newest version, remove it by executing the following command
pip uninstall pycurl
and run the above commands.source: http://pycurl.sourceforge.net/doc/install.html
pycurl 使用 libcurl,并且可以构建 libcurl 以使用多个 TLS 库之一。 GnuTLS 和 OpenSSL 就是其中两个。因此,您可以重建 libcurl 以使用您喜欢的任何一个。
pycurl uses libcurl and libcurl can be built to use one of several TLS libraries. GnuTLS and OpenSSL being two of them. You can thus rebuild libcurl to use whichever of those that you prefer.