Python requests SSL and InsecurePlatformWarning
5 marzo, 2021 por
Python requests SSL and InsecurePlatformWarning
Administrator
| Sin comentarios aún


Every now and then, when using Python 2.7 < 2.7.9 and trying to access SSL resources, especially through the requests toolkit, which seems to trigger the issue frequently – but I’ve seen it on some combinations of pip inside virtualenv as well – you’ll get an error or a warning along those lines:

InsecurePlatformWarning: A true SSLContext object is not  
available. This prevents urllib3 from configuring SSL appropriately and  
may cause certain SSL connections to fail. For more information, see  
https://urllib3.readthedocs.org/en/latest  
/security.html#insecureplatformwarning.

or

SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#snimissingwarning.  
  SNIMissingWarning

or, even worse:

error: SSLError: hostname 'xxx.franzoni.eu' doesn't match either of www.franzoni.eu, franzoni.eu  

This is caused by old libraries in python < 2.7.9 and < 3.4. To fix that, just add to your current virtualenv those three packages:

pip install pyOpenSSL ndg-httpsclient pyasn1  

You may need runtime/development packages for python and openssl as well in order for the build to succeed, e.g. python-dev libssl-dev libffi-dev on Ubuntu 14.04.

 

 

 

apt-get install python3-dev python3-setuptools
Identificarse dejar un comentario