2016-05-18 14 views
6

Ich habe Probleme bekommen tls v1.2 Unterstützung für meine Python-Installation auf meinem Mac.AttributeError: 'Modul' Objekt hat kein Attribut 'PROTOCOL_TLSv1_2' mit Python 2.7.11

Dies ist meine openssl Version:

openssl version 
OpenSSL 1.0.2h 3 May 2016 

Und hier ist meine Python-Version:

python --version 
Python 2.7.11 

Dies ist, wie ich die Prüfung am:

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

das Lesen: https://docs.python.org/2/library/ssl.html Es sagt:

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 habe ich die Anforderungen für die Unterstützung von tlsv1.2 mit meiner Installation von OpenSSL 1.0.2h.

Wer hat irgendwelche Ideen?

+2

Bitte überprüfen Sie, dass Sie nicht nur die neue Version von openssl installiert haben, sondern dass Sie sie tatsächlich in Python verwenden, d. H. 'Import ssl \ nprint ssl.OPENSSL_VERSION' –

+1

Ja, das war das Problem. Ich habe es mit 'brew install python --with-breed-openssl' neu installiert. – gprime

+0

gprime, kannst du das als Antwort schreiben? –

Antwort

2

Das Problem war, dass die OpenSSL-Version, die Python verwendete, TLS 1.2 nicht unterstützte.

Ich installierte openssl mit brauen und dann neu installiert Python sagen es die openssl i mit brauen installiert zu verwenden:

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

Dann funktionierte alles!

+1

Irgendwelche Lösungen, ohne das neueste Python zu installieren? –

+0

Entschuldigung, nicht dass ich davon weiß. – gprime

+1

Gibt es eine ähnliche Lösung für Ubuntu, @gprime? Ich habe das gleiche genaue Problem, aber mit Django auf Ubuntu. – ifconfig

Verwandte Themen