python: fix build with OpenSSL 1.1.0 7446/head
authorAlexandru Ardelean <ardeleanalex@gmail.com>
Fri, 16 Nov 2018 13:33:49 +0000 (15:33 +0200)
committerAlexandru Ardelean <ardeleanalex@gmail.com>
Fri, 16 Nov 2018 13:35:42 +0000 (15:35 +0200)
Addresses issue from here:
  https://github.com/openwrt/packages/issues/7367#issuecomment-437685598

The SSL module in Python doesn't handle properly all the combinations of
NPN between all OpenSSL & LibreSSL versions.
This patch fixes this.
Also pushed a report & proposal upstream to Python:
  https://bugs.python.org/issue35264

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
lang/python/python/Makefile
lang/python/python/patches/011-fix-ssl-build-use-have-npn.patch [new file with mode: 0644]

index 766a57b979443191046786c09b873d91eb575bc5..4a00bfa0f8e46cd4b736d13c411c6d09aa019a5b 100644 (file)
@@ -12,7 +12,7 @@ include ../python-version.mk
 
 PKG_NAME:=python
 PKG_VERSION:=$(PYTHON_VERSION).$(PYTHON_VERSION_MICRO)
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=Python-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=https://www.python.org/ftp/python/$(PKG_VERSION)
diff --git a/lang/python/python/patches/011-fix-ssl-build-use-have-npn.patch b/lang/python/python/patches/011-fix-ssl-build-use-have-npn.patch
new file mode 100644 (file)
index 0000000..b498183
--- /dev/null
@@ -0,0 +1,22 @@
+diff --git a/Modules/_ssl.c b/Modules/_ssl.c
+index a96c419260..c80437eef7 100644
+--- a/Modules/_ssl.c
++++ b/Modules/_ssl.c
+@@ -1586,7 +1586,7 @@ static PyObject *PySSL_version(PySSLSocket *self)
+     return PyUnicode_FromString(version);
+ }
+-#if defined(OPENSSL_NPN_NEGOTIATED) && !defined(OPENSSL_NO_NEXTPROTONEG)
++#if HAVE_NPN
+ static PyObject *PySSL_selected_npn_protocol(PySSLSocket *self) {
+     const unsigned char *out;
+     unsigned int outlen;
+@@ -2114,7 +2114,7 @@ static PyMethodDef PySSLMethods[] = {
+      PySSL_peercert_doc},
+     {"cipher", (PyCFunction)PySSL_cipher, METH_NOARGS},
+     {"version", (PyCFunction)PySSL_version, METH_NOARGS},
+-#ifdef OPENSSL_NPN_NEGOTIATED
++#if HAVE_NPN
+     {"selected_npn_protocol", (PyCFunction)PySSL_selected_npn_protocol, METH_NOARGS},
+ #endif
+ #if HAVE_ALPN