开发者

PyCURL: TLS Handshake Error

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 H开发者_开发问答TTPS 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!


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 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜