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

Support TLS SNI when available.

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.4
    • Affects Version/s: None
    • Component/s: None
    • None

      See DRIVERS-320.

      SNI support is only available in python's ssl module when SSLContext is available. Furthermore, SSLContext.wrap_socket will raise ValueError in some versions of python if the underlying OpenSSL version does not support SNI. The workaround is to check if ssl.HAS_SNI is True. The change to pool.py should look something like:

      # global addition to pool.py
      _HAVE_SNI = False
      try:
          import ssl
          _HAVE_SNI = getattr(ssl, 'HAS_SNI', False)
      except ImportError:
          pass
      
      # change in pool._configured_socket
      if _HAVE_SNI:
          sock = ssl_context.wrap_socket(sock, server_hostname=<hostname>)
      else:
          sock = ssl_context.wrap_socket(sock)
      

            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: