omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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

    Pythonista
    2
    3
    3816
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • mako
      mako last edited by

      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 SSLContext

      If 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?

      1 Reply Last reply Reply Quote 0
      • dgelessus
        dgelessus last edited by dgelessus

        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 for ssl.PROTOCOL_TLSv in the console you'll see that only PROTOCOL_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).

        1 Reply Last reply Reply Quote 0
        • mako
          mako last edited by

          Ah, ok - makes sense. I will port it to Python 3. Thanks!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors