Skip to contentSkip to conversation

python: Building without SSLv3 support

PATCH In review Sona Sarmadi 3 participants 7 messages Dec 3, 2014 – Dec 5, 2014 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 python: Building without SSLv3 support

Building python without SSLv3 support when openssl is built without any support for SSLv3. "OPENSSL_NO_SSL3" is defined in the openssl headers (opensslconf.h) which is located in /usr/include/$arch/openssl/

Backported from:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=768611#22

---
 .../python/python/python2.7.3-nossl3.patch         | 37 ++++++++++++++++++++++
 meta/recipes-devtools/python/python_2.7.3.bb       |  1 +
 2 files changed, 38 insertions(+)
 create mode 100644 meta/recipes-devtools/python/python/python2.7.3-nossl3.patch
meta/recipes-devtools/python/python/python2.7.3-nossl3.patch new file +37 -0
new file mode 100644
index 0000000..2d35520
@@ -0,0 +1,37 @@
+python: Building without SSLv3 support
+
+Building without SSLv3 support when openssl is built
+without any support for SSLv3
+
+Upstream-Status: Backport
+
+Reference:
+https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=76A8611#22
+
+Signed-off-by: Sona Sarmadi <[email protected]>
+---
+diff -ruN a/Modules/_ssl.c b/Modules/_ssl.c
+--- a/Modules/_ssl.c	2014-11-26 07:43:58.755679939 +0100
++++ b/Modules/_ssl.c	2014-11-26 07:49:10.454182400 +0100
+@@ -302,8 +302,10 @@
+     PySSL_BEGIN_ALLOW_THREADS
+     if (proto_version == PY_SSL_VERSION_TLS1)
+         self->ctx = SSL_CTX_new(TLSv1_method()); /* Set up context */
++#ifndef OPENSSL_NO_SSL3
+     else if (proto_version == PY_SSL_VERSION_SSL3)
+         self->ctx = SSL_CTX_new(SSLv3_method()); /* Set up context */
++#endif
+ #ifndef OPENSSL_NO_SSL2
+     else if (proto_version == PY_SSL_VERSION_SSL2)
+         self->ctx = SSL_CTX_new(SSLv2_method()); /* Set up context */
+@@ -1777,8 +1779,10 @@
+     PyModule_AddIntConstant(m, "PROTOCOL_SSLv2",
+                             PY_SSL_VERSION_SSL2);
+ #endif
++#ifndef OPENSSL_NO_SSL3
+     PyModule_AddIntConstant(m, "PROTOCOL_SSLv3",
+                             PY_SSL_VERSION_SSL3);
++#endif
+     PyModule_AddIntConstant(m, "PROTOCOL_SSLv23",
+                             PY_SSL_VERSION_SSL23);
+     PyModule_AddIntConstant(m, "PROTOCOL_TLSv1",
meta/recipes-devtools/python/python_2.7.3.bb +1 -0
index 5270df9..4d2594a 100644
@@ -36,6 +36,7 @@ SRC_URI += "\
   file://python-2.7.3-CVE-2013-1752-smtplib-fix.patch \
   file://python-fix-build-error-with-Readline-6.3.patch \
   file://python-2.7.3-CVE-2014-1912.patch \
+  file://python2.7.3-nossl3.patch \
 "
 
 S = "${WORKDIR}/Python-${PV}"
Signature · 1 line
1.9.1
#1 lore raw
Quoted 7 lines · Sona Sarmadi

Building python without SSLv3 support when openssl is built without any support for SSLv3. "OPENSSL_NO_SSL3" is defined in the openssl headers (opensslconf.h) which is located in /usr/include/$arch/openssl/

Backported from:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=768611#22

This should be applied to master first, and then backported to any stable branches. Can you re-send in a form that applies to master?

Ross

#2 lore raw

Hi Ross,

Sure.

I forgot to make sure that python can be built when "OPENSSL_NO_SSL3" is defined in the openssl. I will check this as well and re-send the patch.

-- Sona

On 3 December 2014 at 08:09, Sona Sarmadi <[email protected]<mailto:[email protected]>> wrote:
Building python without SSLv3 support when openssl is built without
any support for SSLv3. "OPENSSL_NO_SSL3" is defined in the openssl
headers (opensslconf.h) which is located in /usr/include/$arch/openssl/

Backported from:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=768611#22

This should be applied to master first, and then backported to any stable branches. Can you re-send in a form that applies to master?

Ross

#4 lore raw

PATCH 1/1 python: Building without SSLv3 support

In reply to a message not in the archive

Hi guys,

Quoted 4 lines

This should be applied to master first, and then backported to any stable branches.  Can you re-send in a form that applies to master?

Ross

Python has fixed this issue in version 3.5. and backported to 2.7:
See the patch here:
https://hg.python.org/cpython/rev/f762cbb712de

But this patch doesn’t apply, I have downloaded the latest 2.7.8, it is the Same problem there. I have sent email to the guy responsible to this patch but haven't heard from him yet. The commit message also say that " The backport currently doesn't achieve anything since the function isn't used (yet)":

=======================================================
changeset 93549:f762cbb712de 2.7

Backport disabling of SSLv3 in ssl._create_stdlib_context() (issue #22638). The backport currently doesn't achieve anything since the function isn't used
(yet). [#22638]
=======================================================

So this is the reason why I have applied the Debian patch. They disable SSLv3 in python this way because they have disabled SSLv3 in OpenSSL in their Jessie. So if we take Debian's patch we need to define "OPENSSL_NO_SSL3” in the OpenSSL as well. Are you ok with this? (the same way that "OPENSSL_NO_SSL2" is defined in OpenSSL).

ssl/ssl.h
#if (defined(OPENSSL_NO_RSA) || defined(OPENSSL_NO_MD5)) && !defined(OPENSSL_NO_SSL2) #define OPENSSL_NO_SSL2
#endif

Cheers
Sona

#5 lore raw
Quoted 7 lines

Python has fixed this issue in version 3.5. and backported to 2.7:
See the patch here:
https://hg.python.org/cpython/rev/f762cbb712de

But this patch doesn’t apply, I have downloaded the latest 2.7.8, it is the Same problem there. I have sent email to the guy responsible to this patch but haven't heard from him yet.

I got following answer from the guy who has provided python patch above:
"No, it's for 2.7.9. The ssl module in 2.7.9 was backported from Python 3, its code is vastly different. 2.7.9 should be released soon in December or January."

So we either upgrade master to 2.7.9 when python 2.7.9 is released (if this is ok) otherwise use the Debian's patch.

Any comment?

/S

#6 lore raw
Quoted 11 lines · On Friday 05 December 2014 15:32:05 Sona Sarmadi wrote:
Quoted 9 lines

Python has fixed this issue in version 3.5. and backported to 2.7:
See the patch here:

https://hg.python.org/cpython/rev/f762cbb712de

But this patch doesn’t apply, I have downloaded the latest 2.7.8, it is the Same problem there. I have sent email to the guy responsible to this patch but haven't heard from him yet.

Quoted 8 lines

I got following answer from the guy who has provided python patch above:
"No, it's for 2.7.9. The ssl module in 2.7.9 was backported from Python 3, its code is vastly different. 2.7.9 should be released soon in December or January."

So we either upgrade master to 2.7.9 when python 2.7.9 is released (if this is ok) otherwise use
the Debian's patch.

I think we should apply the patch now anyway; we'll want to know that it works for backports to the stable branch(es), and in any case the upgrade to 2.7.9 is not going to be a straightforward task based upon my earlier attempt to upgrade to 2.7.6 (the current state of which is still in paule/python276-wip in poky-contrib).

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre
#7 lore raw
Quoted 20 lines · On Friday 05 December 2014 15:46:21 Paul Eggleton wrote:
Quoted 14 lines · On Friday 05 December 2014 15:32:05 Sona Sarmadi wrote:
Quoted 8 lines

Python has fixed this issue in version 3.5. and backported to 2.7:

See the patch here:
https://hg.python.org/cpython/rev/f762cbb712de

But this patch doesn’t apply, I have downloaded the latest 2.7.8, it is the Same problem there. I have sent email to the guy responsible to this patch but haven't heard from him yet.

I got following answer from the guy who has provided python patch above:
"No, it's for 2.7.9. The ssl module in 2.7.9 was backported from Python 3, its code is vastly different. 2.7.9 should be released soon in December or January."

Quoted 4 lines

So we either upgrade master to 2.7.9 when python 2.7.9 is released (if this
is ok) otherwise use
the Debian's patch.

Quoted 5 lines

I think we should apply the patch now anyway; we'll want to know that it works for backports to the stable branch(es), and in any case the upgrade to 2.7.9 is not going to be a straightforward task based upon my earlier attempt to upgrade to 2.7.6 (the current state of which is still in paule/python276-wip in poky-contrib).

(In case it's perhaps not clear from the above - I'm not discouraging the upgrade to 2.7.9, I think a python upgrade is long overdue, and we should definitely do it.)

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre