Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
TLS 1.2 / Python 2.7
-
Hello -
Im trying to get TLS 1.2 working in a script by setting the SSLContext to PROTOCOL_TLSv1_2 -
ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) resp = urllib2.urlopen(req, context=ctx)
And I keep getting the following error:
'module' object has no attribute SSLContextIf I go to the console and print ssl.OPENSSL_VERSION, it returns OpenSSL 1.0.1g (so I thought TLS1.2 is supported)...
Any thoughts how how to get TLS1.2 in Python 2.7 working?
-
The
SSLContext
class was backported from Python 3, in this commit dated 20 August 2014, which means that it is only available as of Python 2.7.9 (released on 10 December 2014 - see the release notes). Pythonista 2 and 3 use Python 2.7.5, which means that this functionality is not available.This wouldn't be a major issue - you'd simply need to use the old
ssl.wrap_socket
function and some extra manual work - but Pythonista's Python version also doesn't support TLS1.2, if you check the completion suggestions forssl.PROTOCOL_TLSv
in the console you'll see that onlyPROTOCOL_TLSv1
is listed.The Python 3 version included with Pythonista 3 (Python 3.5.1) is much newer and supports all of the features that you want, so if you have Pythonista 3, you should try writing your code in Python 3 and/or porting your existing code (if any).
-
Ah, ok - makes sense. I will port it to Python 3. Thanks!