httpretty.disable() injects pyopenssl into urllib3 even if it originally wasn't
ento opened this issue · comments
MCVE: https://gist.github.com/ento/e1e33d7d67e406bf03fe61f018404c21
Excerpt:
$ python test_httpretty_pyopenssl.py
test_without_httpretty
urllib3.util.IS_PYOPENSSL is False
test_enable_disable_httpretty
urllib3.util.IS_PYOPENSSL is True
HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))
test_enable_disable_httpretty_then_extract_from_urllib3
urllib3.util.IS_PYOPENSSL is False
This can cause subsequent uses of the urllib3 library to fail with SSLError when the execution environment is somehow incompatible with pyopenssl.
Current workaround: extract pyopenssl from urllib3 manually after calling httpretty.disable()
:
from urllib3.contrib.pyopenssl import extract_from_urllib3
extract_from_urllib3()
Fixed in the release 1.1.1