11

I am having issues getting tls v1.2 support for my python installation on my mac.

This is my openssl version:

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 am testing:

>>> 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'

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

Some behavior may be platform dependent, since calls are made to the operating system socket APIs. The installed version of OpenSSL may also cause variations in behavior. For example, TLSv1.1 and TLSv1.2 come with openssl version 1.0.1.

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

Anyone have any ideas?

3
  • 2
    Please check that you have not only installed the new version of openssl but that you actually use it inside python, i.e. import ssl\nprint ssl.OPENSSL_VERSION Commented May 18, 2016 at 18:33
  • 1
    Yeah, that was the problem. I reinstalled with 'brew install python --with-brewed-openssl'. Commented May 18, 2016 at 18:49
  • gprime, can you write that as an answer ? Commented Sep 8, 2016 at 12:31

1 Answer 1

4

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

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

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

Then everything worked!

Sign up to request clarification or add additional context in comments.

5 Comments

Any solutions without installing latest Python?
Sorry, not that I know of.
Is there a similar solution for ubuntu, @gprime ? I have the same exact issue, but with Django on Ubuntu.
trying this today: Error: invalid option: --with-brewed-openssl
appear homebrew basically "already uses a brewed openssl" no matter what these days (though a specific version, do brew edit python to see which)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.