Browse Source

[desktop] requests should only set tls hostname if supported

The ssl SNI allows a request to set the expected hostname as part of the SSL handshake, but SUSE11 doesn't support this mechanism. As a workaround, this patch checks if the method `set_tlsext_host_name` was enabled, and only uses it if it was compiled into PyOpenSSL.
Jenny Kim 9 years ago
parent
commit
d381bf4

+ 3 - 1
desktop/core/ext-py/requests-2.10.0/requests/packages/urllib3/contrib/pyopenssl.py

@@ -341,7 +341,9 @@ def ssl_wrap_socket(sock, keyfile=None, certfile=None, cert_reqs=None,
     cnx = OpenSSL.SSL.Connection(ctx, sock)
     if isinstance(server_hostname, six.text_type):  # Platform-specific: Python 3
         server_hostname = server_hostname.encode('utf-8')
-    cnx.set_tlsext_host_name(server_hostname)
+    # Hue Patch: Only set the SNI hostname if PyOpenSSL supports it.
+    if hasattr(cnx, 'set_tlsext_host_name'):
+        cnx.set_tlsext_host_name(server_hostname)
     cnx.set_connect_state()
     while True:
         try: