question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Need to update error handling for pyOpenSSL

See original GitHub issue

If an SSLError comes from pyOpenSSL, we attempt to determine if it’s an error due to request timeouts on python 2.6 being raised as BaseSSLErrors here. If the handshake ends unexpectedly under pyOpenSSL, then we get an SSLError that has a captured SysCallError which when you call str(SSLError(msg, SysCallError(code, msg))) you get

TypeError: __str__ returned non-string (type SysCallError)

So we might want to update how we handle SSLErrors to accomodate pyOpenSSL. To be clear, I observed this on: python 2.7.9 with openssl 1.0.1l (from brew) and I was using requests to debug an issue with https://apissl.cloudfactory.com, e.g., requests.get('https://apissl.cloudfactory.com')

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:1
  • Comments:29 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
lorenzogcommented, Jun 26, 2015

I had to fix this on a production server by editing requests/packages/urllib3/connectionpool.py. At line 315, before if 'timed out' in str(err) or 'did not complete (read)' in str(err): I inserted:

if not isinstance(err, str) and hasattr(err, 'strerror'):
        raise ProtocolError(self, url, "{}".format(err.strerror))

At least I get some inkling on what’s going on - in my case this bubbles up to my application from requests as:

requests.exceptions.ConnectionError: (<requests.packages.urllib3.connectionpool.HTTPSConnectionPool object at 0x7f3999ba18d0>, ‘/’, “[(‘SSL routines’, ‘SSL3_GET_SERVER_CERTIFICATE’, ‘certificate verify failed’)]”)

1reaction
shazowcommented, Feb 28, 2015

Yea that whole process is voodoo. 😕

Open to basically any kind of change. What do you have in mind?

Read more comments on GitHub >

github_iconTop Results From Across the Web

openssl - easy_install PyOpenSSL error - Stack Overflow
In order to install it under virtualenv, you should first install the required packages. On ubuntu: sudo apt-get install python-dev ...
Read more >
Installation — pyOpenSSL 22.1.0 documentation
To install pyOpenSSL: $ pip install pyopenssl. If you are installing in order to develop on pyOpenSSL, move to the root directory of...
Read more >
[Fixed] ModuleNotFoundError: No module named 'pyopenssl'
Quick Fix: Python raises the ImportError: No module named 'pyopenssl' when it cannot find the library pyopenssl . The most frequent source of...
Read more >
[Fix] ImportError: 'pyOpenSSL' module missing required ...
When running certbot commands, you get an error like the following: ImportError: 'pyOpenSSL' module missing required functionality. Try  ...
Read more >
pyOpenSSL · PyPI
Extensive error-handling mechanism, mirroring OpenSSL's error codes ... X509StoreContextError exception has been refactored, changing its internal ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found