GeezerVison is showing github.com — bpo-43794: OpenSSL 3.0.0: set OP_IGNORE_UNEXPECTED_EOF by default (GH… · python/cpython@6f37ebc
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: Doc/library/ssl.rst +8Lines changed: 8 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -893,6 +893,14 @@ Constants | 893 | 893 |
| 894 | 894 | .. versionadded:: 3.6 | 895 | 895 |
| | 896 | +.. data:: OP_IGNORE_UNEXPECTED_EOF | | 897 | + | | 898 | + Ignore unexpected shutdown of TLS connections. | | 899 | + | | 900 | + This option is only available with OpenSSL 3.0.0 and later. | | 901 | + | | 902 | + .. versionadded:: 3.10 | | 903 | + | 896 | 904 | .. data:: HAS_ALPN | 897 | 905 |
| 898 | 906 | Whether the OpenSSL library has built-in support for the *Application-Layer | |
Collapse file Copy file name to clipboardExpand all lines: Lib/test/test_ssl.py +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -151,6 +151,7 @@ def data_file(*name): | 151 | 151 | OP_SINGLE_ECDH_USE = getattr(ssl, "OP_SINGLE_ECDH_USE", 0) | 152 | 152 | OP_CIPHER_SERVER_PREFERENCE = getattr(ssl, "OP_CIPHER_SERVER_PREFERENCE", 0) | 153 | 153 | OP_ENABLE_MIDDLEBOX_COMPAT = getattr(ssl, "OP_ENABLE_MIDDLEBOX_COMPAT", 0) | | 154 | +OP_IGNORE_UNEXPECTED_EOF = getattr(ssl, "OP_IGNORE_UNEXPECTED_EOF", 0) | 154 | 155 |
| 155 | 156 | # Ubuntu has patched OpenSSL and changed behavior of security level 2 | 156 | 157 | # see https://bugs.python.org/issue41561#msg389003 | @@ -1168,7 +1169,8 @@ def test_options(self): | 1168 | 1169 | # SSLContext also enables these by default | 1169 | 1170 | default |= (OP_NO_COMPRESSION | OP_CIPHER_SERVER_PREFERENCE | | 1170 | 1171 | OP_SINGLE_DH_USE | OP_SINGLE_ECDH_USE | | 1171 | | - OP_ENABLE_MIDDLEBOX_COMPAT) | | 1172 | + OP_ENABLE_MIDDLEBOX_COMPAT | | | 1173 | + OP_IGNORE_UNEXPECTED_EOF) | 1172 | 1174 | self.assertEqual(default, ctx.options) | 1173 | 1175 | ctx.options |= ssl.OP_NO_TLSv1 | 1174 | 1176 | self.assertEqual(default | ssl.OP_NO_TLSv1, ctx.options) | |
Collapse file Copy file name to clipboard +1Lines changed: 1 addition & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +Add :data:`ssl.OP_IGNORE_UNEXPECTED_EOF` constants (OpenSSL 3.0.0) |
Collapse file Copy file name to clipboardExpand all lines: Modules/_ssl.c +8Lines changed: 8 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -3202,6 +3202,10 @@ _ssl__SSLContext_impl(PyTypeObject *type, int proto_version) | 3202 | 3202 | #endif | 3203 | 3203 | #ifdef SSL_OP_SINGLE_ECDH_USE | 3204 | 3204 | options |= SSL_OP_SINGLE_ECDH_USE; | | 3205 | +#endif | | 3206 | +#ifdef SSL_OP_IGNORE_UNEXPECTED_EOF | | 3207 | + /* Make OpenSSL 3.0.0 behave like 1.1.1 */ | | 3208 | + options |= SSL_OP_IGNORE_UNEXPECTED_EOF; | 3205 | 3209 | #endif | 3206 | 3210 | SSL_CTX_set_options(self->ctx, options); | 3207 | 3211 |
| @@ -6313,6 +6317,10 @@ sslmodule_init_constants(PyObject *m) | 6313 | 6317 | PyModule_AddIntConstant(m, "OP_NO_RENEGOTIATION", | 6314 | 6318 | SSL_OP_NO_RENEGOTIATION); | 6315 | 6319 | #endif | | 6320 | +#ifdef SSL_OP_IGNORE_UNEXPECTED_EOF | | 6321 | + PyModule_AddIntConstant(m, "OP_IGNORE_UNEXPECTED_EOF", | | 6322 | + SSL_OP_IGNORE_UNEXPECTED_EOF); | | 6323 | +#endif | 6316 | 6324 |
| 6317 | 6325 | #ifdef X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT | 6318 | 6326 | PyModule_AddIntConstant(m, "HOSTFLAG_ALWAYS_CHECK_SUBJECT", | |
|