From 43cf0ec87058b247188fd1c7d906265eef07214c Mon Sep 17 00:00:00 2001 From: karl ding Date: Tue, 2 Jun 2020 00:19:18 -0700 Subject: [PATCH] ssl: Improve SSLContext.options stub (#4152) In Python 3.6, the SSLContext.options flags were converted from int to EnumFlag values. In addition, add the missing OP_ENABLE_MIDDLEBOX_COMPAT constant introduced in version 3.6. In addition, add the missing OP_NO_RENEGOTIATION constant introduced in version 3.7. --- stdlib/2and3/ssl.pyi | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/stdlib/2and3/ssl.pyi b/stdlib/2and3/ssl.pyi index 5eafefa7a..b0545d01e 100644 --- a/stdlib/2and3/ssl.pyi +++ b/stdlib/2and3/ssl.pyi @@ -139,18 +139,33 @@ if sys.version_info >= (3, 6): PROTOCOL_TLS_CLIENT: int PROTOCOL_TLS_SERVER: int -OP_ALL: int -OP_NO_SSLv2: int -OP_NO_SSLv3: int -OP_NO_TLSv1: int -OP_NO_TLSv1_1: int -OP_NO_TLSv1_2: int -OP_CIPHER_SERVER_PREFERENCE: int -OP_SINGLE_DH_USE: int -OP_SINGLE_ECDH_USE: int -OP_NO_COMPRESSION: int if sys.version_info >= (3, 6): - OP_NO_TICKET: int + class Options(enum.IntFlag): + OP_ALL: int + OP_NO_SSLv2: int + OP_NO_SSLv3: int + OP_NO_TLSv1: int + OP_NO_TLSv1_1: int + OP_NO_TLSv1_2: int + OP_CIPHER_SERVER_PREFERENCE: int + OP_SINGLE_DH_USE: int + OP_SINGLE_ECDH_USE: int + OP_NO_COMPRESSION: int + OP_NO_TICKET: int + OP_ENABLE_MIDDLEBOX_COMPAT: int + if sys.version_info >= (3, 7): + OP_NO_RENEGOTIATION: int +else: + OP_ALL: int + OP_NO_SSLv2: int + OP_NO_SSLv3: int + OP_NO_TLSv1: int + OP_NO_TLSv1_1: int + OP_NO_TLSv1_2: int + OP_CIPHER_SERVER_PREFERENCE: int + OP_SINGLE_DH_USE: int + OP_SINGLE_ECDH_USE: int + OP_NO_COMPRESSION: int HAS_ALPN: int HAS_ECDH: bool @@ -248,7 +263,10 @@ if sys.version_info >= (3, 7): class SSLContext: check_hostname: bool - options: int + if sys.version_info >= (3, 6): + options: Options + else: + options: int if sys.version_info >= (3, 8): post_handshake_auth: bool @property