AttributeError: the 'module' object does not have the 'PROTOCOL_TLSv1_2' attribute since Python 2.7.11

I'm having problems getting tls v1.2 support for my python installation on my mac.

This is my version of openssl:

openssl version OpenSSL 1.0.2h 3 May 2016 

And here is my python version:

 python --version Python 2.7.11 

This is how I test:

 >>> import ssl >>> ssl.PROTOCOL_TLSv1_2 Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'module' object has no attribute 'PROTOCOL_TLSv1_2' 

Read: https://docs.python.org/2/library/ssl.html It says:

Some behavior may be platform dependent, because calls are APIs of the operating system. An installed version of OpenSSL may also cause behavioral changes. For example, TLSv1.1 and TLSv1.2 ship with openssl version 1.0.1.

So, I have tlsv1.2 support requirements with my installation of OpenSSL 1.0.2h.

Does anyone have any ideas?

+6
source share
1 answer

The problem was that the python version of openssl used did not support TLS 1.2.

I installed openssl using brew and then reinstalled python telling it to use openssl i installed using brew:

 $ brew update $ brew install openssl $ brew install python --with-brewed-openssl 

Then it worked!

+2
source

All Articles