Преглед изворни кода

HUE-902 [core] Include modified pyOpenSSL 0.13 version

This version has conditional inclusion of SNI extension bindings.
It should solve openssl <0.9.8e version problems.
Its own tests will not work, so they've been removed.
abec пре 13 година
родитељ
комит
4206c72

+ 8 - 0
desktop/core/ext-py/pyopenssl/OpenSSL/ssl/connection.c

@@ -263,6 +263,11 @@ ssl_Connection_get_context(ssl_ConnectionObj *self, PyObject *args) {
     return (PyObject *)self->context;
 }
 
+// Only provide a TLS servername extension host name value
+// when it is actually installed.
+// This is used to get around the deficiencies of openSSL 0.9.8e and older.
+#if SNI_EXTENSION_SUPPORT
+
 static char ssl_Connection_set_context_doc[] = "\n\
 Switch this connection to a new session context\n\
 \n\
@@ -349,6 +354,7 @@ ssl_Connection_set_tlsext_host_name(ssl_ConnectionObj *self, PyObject *args) {
     return Py_None;
 }
 
+#endif
 
 
 static char ssl_Connection_pending_doc[] = "\n\
@@ -1269,9 +1275,11 @@ ssl_Connection_want_write(ssl_ConnectionObj *self, PyObject *args)
 static PyMethodDef ssl_Connection_methods[] =
 {
     ADD_METHOD(get_context),
+#if SNI_EXTENSION_SUPPORT
     ADD_METHOD(set_context),
     ADD_METHOD(get_servername),
     ADD_METHOD(set_tlsext_host_name),
+#endif
     ADD_METHOD(pending),
     ADD_METHOD(send),
     ADD_ALIAS (write, send),

+ 8 - 0
desktop/core/ext-py/pyopenssl/OpenSSL/ssl/context.c

@@ -237,6 +237,7 @@ global_info_callback(const SSL *ssl, int where, int _ret)
     return;
 }
 
+#if SNI_EXTENSION_SUPPORT
 /*
  * Globally defined TLS extension server name callback.  This is called from
  * OpenSSL internally.  The GIL will not be held when this function is invoked.
@@ -275,6 +276,7 @@ global_tlsext_servername_callback(const SSL *ssl, int *alert, void *arg) {
     MY_BEGIN_ALLOW_THREADS(conn->tstate);
     return result;
 }
+#endif
 
 /*
  * More recent builds of OpenSSL may have SSLv2 completely disabled.
@@ -1108,6 +1110,7 @@ ssl_Context_set_options(ssl_ContextObj *self, PyObject *args)
     return PyLong_FromLong(SSL_CTX_set_options(self->ctx, options));
 }
 
+#if SNI_EXTENSION_SUPPORT
 static char ssl_Context_set_tlsext_servername_callback_doc[] = "\n\
 Specify a callback function to be called when clients specify a server name.\n\
 \n\
@@ -1135,6 +1138,7 @@ ssl_Context_set_tlsext_servername_callback(ssl_ContextObj *self, PyObject *args)
     Py_INCREF(Py_None);
     return Py_None;
 }
+#endif
 
 
 /*
@@ -1174,7 +1178,9 @@ static PyMethodDef ssl_Context_methods[] = {
     ADD_METHOD(set_app_data),
     ADD_METHOD(get_cert_store),
     ADD_METHOD(set_options),
+#if SNI_EXTENSION_SUPPORT
     ADD_METHOD(set_tlsext_servername_callback),
+#endif
     { NULL, NULL }
 };
 #undef ADD_METHOD
@@ -1222,8 +1228,10 @@ ssl_Context_init(ssl_ContextObj *self, int i_method) {
     Py_INCREF(Py_None);
     self->info_callback = Py_None;
 
+#if SNI_EXTENSION_SUPPORT
     Py_INCREF(Py_None);
     self->tlsext_servername_callback = Py_None;
+#endif
 
     Py_INCREF(Py_None);
     self->passphrase_userdata = Py_None;

+ 2 - 0
desktop/core/ext-py/pyopenssl/OpenSSL/ssl/context.h

@@ -29,7 +29,9 @@ typedef struct {
                         *passphrase_userdata,
                         *verify_callback,
                         *info_callback,
+#if SNI_EXTENSION_SUPPORT
                         *tlsext_servername_callback,
+#endif
                         *app_data;
     PyThreadState       *tstate;
 } ssl_ContextObj;

+ 6 - 0
desktop/core/ext-py/pyopenssl/OpenSSL/ssl/ssl.h

@@ -14,6 +14,12 @@
 #define PyOpenSSL_SSL_H_
 
 #include <Python.h>
+#include <openssl/ssl.h>
+
+#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER > 0x009080efL
+  #define SNI_EXTENSION_SUPPORT 1
+#endif
+
 #include <pythread.h>
 #include "context.h"
 #include "connection.h"