Search code examples
pythonpython-2.7sslhttplib2

Python httplib2 "httplib2.SSLHandshakeError"


I have this piece of code that tries to get the page content from a given url.

import httplib2

start_url = "https://www.somesite.com"
http = httplib2.Http(disable_ssl_certificate_validation=True)
status, response = http.request(start_url)

However, when I run it, I get this error:

Traceback (most recent call last):   File "C:\Documents and Settings\DD\Desktop\crawler.py", line 15, in <module>
    resp, content = h.request(start_url, "GET")   File "C:\Python27\lib\site-packages\httplib2-0.9-py2.7.egg\httplib2\__init__.py", line 1593, in request
    (response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)   File "C:\Python27\lib\site-packages\httplib2-0.9-py2.7.egg\httplib2\__init__.py", line 1335, in _request
    (response, content) = self._conn_request(conn, request_uri, method, body, headers)   File "C:\Python27\lib\site-packages\httplib2-0.9-py2.7.egg\httplib2\__init__.py", line 1257, in _conn_request
    conn.connect()   File "C:\Python27\lib\site-packages\httplib2-0.9-py2.7.egg\httplib2\__init__.py", line 1044, in connect
    raise SSLHandshakeError(e) httplib2.SSLHandshakeError: [Errno 1] _ssl.c:510: error:1408F119:SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac

As you may have seen, I tried to disable the ssl validation but with no succsess. Any Help? Thanks!


Solution

  • SSL3_GET_RECORD:decryption failed or bad record mac

    This has nothing to do with SSL validation. It might be that the server simply does not talk SSL or that there are other SSL related problems, but validation is not one of them at this stage of communication.

    If you provide the real URL or a full packet capture (file or at cloudshark.org) one might analyze the information in more detail.