[pypy-commit] pypy stdlib-2.7.16: add _ssl.HAS_TLSv1_3

mattip pypy.commits at gmail.com
Mon May 20 07:30:44 EDT 2019


Author: Matti Picus <matti.picus at gmail.com>
Branch: stdlib-2.7.16
Changeset: r96644:c59a0f5fdb0d
Date: 2019-05-19 23:14 +0300
http://bitbucket.org/pypy/pypy/changeset/c59a0f5fdb0d/

Log:	add _ssl.HAS_TLSv1_3

diff --git a/pypy/module/_ssl/interp_ssl.py b/pypy/module/_ssl/interp_ssl.py
--- a/pypy/module/_ssl/interp_ssl.py
+++ b/pypy/module/_ssl/interp_ssl.py
@@ -103,7 +103,10 @@
 constants["OPENSSL_VERSION_INFO"] = version_info
 constants["_OPENSSL_API_VERSION"] = version_info
 constants["OPENSSL_VERSION"] = SSLEAY_VERSION
-
+if OPENSSL_NO_TLS1_3:
+    constants["HAS_TLSv1_3"] = 0
+else:
+    constants["HAS_TLSv1_3"] = TLS1_3_VERSION
 
 def ssl_error(space, msg, errno=0, w_errtype=None, errcode=0):
     reason_str = None
diff --git a/pypy/module/_ssl/test/test_ssl.py b/pypy/module/_ssl/test/test_ssl.py
--- a/pypy/module/_ssl/test/test_ssl.py
+++ b/pypy/module/_ssl/test/test_ssl.py
@@ -42,6 +42,7 @@
         assert 'openssl' in lower_version or "libressl" in lower_version
 
         assert isinstance(_ssl.ALERT_DESCRIPTION_ACCESS_DENIED, int)
+        assert isinstance(_ssl.HAS_TLSv1_3, int)
 
     def test_RAND_add(self):
         import _ssl
diff --git a/rpython/rlib/ropenssl.py b/rpython/rlib/ropenssl.py
--- a/rpython/rlib/ropenssl.py
+++ b/rpython/rlib/ropenssl.py
@@ -132,6 +132,8 @@
         SSL_OP_NO_TLSv1_1 = rffi_platform.ConstantInteger("SSL_OP_NO_TLSv1_1")
         SSL_OP_NO_TLSv1_2 = rffi_platform.ConstantInteger("SSL_OP_NO_TLSv1_2")
     OPENSSL_NO_TLSEXT = rffi_platform.Defined("OPENSSL_NO_TLSEXT")
+    OPENSSL_NO_TLS1_3 = rffi_platform.Defined("OPENSSL_NO_TLS1_3")
+    TLS1_3_VERSION = rffi_platform.Defined("TLS1_3_VERSION")
     SSL_OP_CIPHER_SERVER_PREFERENCE = rffi_platform.ConstantInteger(
         "SSL_OP_CIPHER_SERVER_PREFERENCE")
     SSL_OP_SINGLE_DH_USE = rffi_platform.ConstantInteger(


More information about the pypy-commit mailing list