Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1230

Use ssl.PROTOCOL_TLS_CLIENT when available (3.x)

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.5
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      ssl.PROTOCOL_TLS_CLIENT was added in Python 3.6 related to support for OpenSSL 1.1. ssl.PROTOCOL_SSLv23 is now deprecated. Create SSLContext like this:

      ctx = SSLContext(getattr(ssl, 'PROTOCOL_TLS_CLIENT', ssl.PROTOCOL_SSLv23))
      

      Though PROTOCOL_TLS was added at the same time as PROTOCOL_TLS_CLIENT, http://bugs.python.org/issue28085 makes it clear that PROTOCOL_TLS won't be available for long, so we shouldn't use it.

      PROTOCOL_TLS_CLIENT enables SSLContext.check_hostname by default. This causes the context object to call match_hostname in its do_handshake routine. We already call match_hostname ourselves when creating a new socket. We'll have to make sure match_hostname isn't being called twice, once by us and once by SSLContext.

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            bernie@mongodb.com Bernie Hackett
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: