Try to ensure a sound SSL environment for the process
If the python version is < 2.7.9, we try to patch urllib3 with pyopenssl to get rid of any InsecurePlatform issues. That only works if pyopenssl plus dependencies are installed however, hence we also log that.
This commit is contained in:
parent
d373d257e3
commit
70fb385650
1 changed files with 30 additions and 0 deletions
|
|
@ -21,6 +21,36 @@ del get_versions
|
|||
|
||||
logging.basicConfig()
|
||||
|
||||
#~~ try to ensure a sound SSL environment
|
||||
|
||||
version_info = sys.version_info
|
||||
if version_info.major == 2 and version_info.minor <= 7 and version_info.micro < 9:
|
||||
message = "Cannot configure PyOpenSSL for {} to ensure a secure " + \
|
||||
"SSL environment, update to Python >= 2.7.9 or install PyOpenSSL, see " + \
|
||||
"https://urllib3.readthedocs.org/en/latest/security.html#openssl-pyopenssl"
|
||||
|
||||
try:
|
||||
# make sure our requests version of urllib3 is properly patched (if possible)
|
||||
import requests.packages.urllib3.contrib.pyopenssl
|
||||
requests.packages.urllib3.contrib.pyopenssl.inject_into_urllib3()
|
||||
except ImportError:
|
||||
logging.getLogger(__name__).warn(message.format("requests/urllib3"))
|
||||
|
||||
try:
|
||||
import urllib3
|
||||
|
||||
# only proceed if urllib3 is even installed on its own
|
||||
try:
|
||||
# urllib3 is there, let's patch that too
|
||||
import urllib3.contrib.pyopenssl
|
||||
urllib3.contrib.pyopenssl.inject_into_urllib3()
|
||||
except ImportError:
|
||||
logging.getLogger(__name__).warn(message.format("urllib3"))
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
del version_info
|
||||
|
||||
#~~ init methods to bring up platform
|
||||
|
||||
def init_platform(basedir, configfile, use_logging_file=True, logging_file=None,
|
||||
|
|
|
|||
Loading…
Reference in a new issue