Skip to content

Instantly share code, notes, and snippets.

@muffl0n
Last active January 28, 2016 07:43
Show Gist options
  • Save muffl0n/2ae432dbb3ff161a5b20 to your computer and use it in GitHub Desktop.
Save muffl0n/2ae432dbb3ff161a5b20 to your computer and use it in GitHub Desktop.
PyCurl: 'GnuTLS recv error (-9): A TLS packet with unexpected length was received.'
from __future__ import print_function
import pycurl
print(pycurl.version)
c = pycurl.Curl()
c.setopt(pycurl.URL, 'https://packages.graylog2.org/repo/debian/dists/trusty/0.92/binary-amd64/Packages')
c.setopt(pycurl.PROXY, 'my_proxy')
c.setopt(pycurl.PROXYPORT, 8080)
c.setopt(pycurl.PROXYUSERPWD, 'xxx:yyy')
c.setopt(pycurl.HTTPPROXYTUNNEL, 1)
c.perform()
print("HTTP-Status-Code: ", c.getinfo(pycurl.HTTP_CODE))
"""
-----------
# python curl.py
PycURL/7.19.3 libcurl/7.35.0 GnuTLS/2.12.23 zlib/1.2.8 libidn/1.28 librtmp/2.3
Traceback (most recent call last):
File "curl.py", line 14, in <module>
print(c.perform())
pycurl.error: (56, 'GnuTLS recv error (-9): A TLS packet with unexpected length was received.')
-----------
After
'apt-get install libcurl4-openssl-dev libssl-dev libpython-dev'
and
'sudo pip install pycurl --upgrade'
-----------
# python curl.py
PycURL/7.21.5 libcurl/7.35.0 OpenSSL/1.0.1f zlib/1.2.8 libidn/1.28 librtmp/2.3
HTTP-Status-Code: 302
-----------
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment