Tag Archives: InsecurePlatformWarning: A true SSLContext object is not available

When running Python script, an error is reported: a true sslcontext object is not available

Why can’t you stop buying 618?From the technical dimension to explore>>>

Today, to run a python script in a new environment, we encountered the following error:

/usr/lib/python2.7/site-packages/urllib3/util/ssl_. py:160: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a new……

The error report is related to the security policy. I searched online because of the python Version (using python2.7.5). The solution is to either upgrade the python version or install requests

Based on the principle of minimum influence, it is decided to adopt the latter as follows:

pip install requests[security]

After the installation is completed, run the python script again, and the same error is reported. I tried again

PIP install pyopenssl NDG httpclient pyasn1 (equivalent to installing requests)

After the installation is completed, rerun the python script and report the same error. I think of a common trick upgrade

pip install –upgrade requests[security]

After the installation is completed, run the python script again. As expected, no longer report the error of insure platform warning

Digression: there is no mistake in insure platform warning, but another mistake, cryptographicdecrecation warning, has been reported. The details are as follows:

/usr/lib64/python2.7/site-packages/cryptography/hazmat/primitives/constant_ time.py:26: CryptographyDeprecationWarning: Support for your Python version is deprecated. The next version of cryptography will remove support. Please upgrade to a 2.7.x release that supports hmac.compare_ digest as soon as possible.

utils.DeprecatedIn23

Remind to upgrade the python version, but at this time the script does not involve security, it can be executed normally