dev-python/pypy3: Backport servername_callback fix

Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
Michał Górny
2021-02-10 00:34:56 +01:00
parent 81fb614503
commit ba21d61bf2
2 changed files with 41 additions and 1 deletions

View File

@@ -0,0 +1,38 @@
diff -dupr a/lib_pypy/_cffi_ssl/_stdssl/__init__.py b/lib_pypy/_cffi_ssl/_stdssl/__init__.py
--- a/lib_pypy/_cffi_ssl/_stdssl/__init__.py 2021-02-10 00:15:40.815208732 +0100
+++ b/lib_pypy/_cffi_ssl/_stdssl/__init__.py 2021-02-10 00:19:27.963109365 +0100
@@ -1008,10 +1008,10 @@ for name in SSL_CTX_STATS_NAMES:
SSL_CTX_STATS.append((name, getattr(lib, attr)))
class _SSLContext(object):
- __slots__ = ('ctx', '_check_hostname', 'servername_callback',
+ __slots__ = ('ctx', '_check_hostname',
'alpn_protocols', '_alpn_protocols_handle', '_protocol'
'npn_protocols', 'set_hostname', '_post_handshake_auth',
- '_sni_cb', '_npn_protocols_handle')
+ '_sni_cb', '_sni_cb_handle', '_npn_protocols_handle')
def __new__(cls, protocol):
self = object.__new__(cls)
self.ctx = ffi.NULL
@@ -1451,15 +1451,17 @@ class _SSLContext(object):
"is not in the current OpenSSL library.")
if cb is None:
lib.SSL_CTX_set_tlsext_servername_callback(self.ctx, ffi.NULL)
- self._sni_cb= None
+ self._sni_cb = None
+ lib.SSL_CTX_set_tlsext_servername_arg(self.ctx, ffi.NULL)
+ self._sni_cb_handle = None
return
if not callable(cb):
lib.SSL_CTX_set_tlsext_servername_callback(self.ctx, ffi.NULL)
raise TypeError("not a callable object")
- self.scb = ServernameCallback(cb, self)
- sni_cb = ffi.new_handle(self.scb)
+ self._sni_cb = ServernameCallback(cb, self)
+ self._sni_cb_handle = ffi.new_handle(self._sni_cb)
lib.SSL_CTX_set_tlsext_servername_callback(self.ctx, _servername_callback)
- lib.SSL_CTX_set_tlsext_servername_arg(self.ctx, sni_cb)
+ lib.SSL_CTX_set_tlsext_servername_arg(self.ctx, self._sni_cb_handle)
def cert_store_stats(self):
store = lib.SSL_CTX_get_cert_store(self.ctx)

View File

@@ -1,4 +1,4 @@
# Copyright 1999-2020 Gentoo Authors
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
@@ -50,6 +50,8 @@ src_prepare() {
eapply "${FILESDIR}/7.3.1-gentoo-path.patch"
eapply "${FILESDIR}/1.9-distutils.unixccompiler.UnixCCompiler.runtime_library_dir_option.patch"
eapply "${FILESDIR}/7.3.2-py37-distutils-cxx.patch"
# https://foss.heptapod.net/pypy/pypy/-/issues/3396
eapply "${FILESDIR}/7.3.3_p37-sni-handle.patch"
sed -e "s^@EPREFIX@^${EPREFIX}^" \
-i lib-python/3/distutils/command/install.py || die