File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1135,6 +1135,16 @@ def test_set_server_sigalgs(self):
11351135 if CAN_IGNORE_UNKNOWN_OPENSSL_SIGALGS :
11361136 self .assertIsNone (ctx .set_server_sigalgs ('rsa_pss_rsae_sha256:?foo' ))
11371137
1138+ @unittest .skipUnless (CAN_GET_SELECTED_OPENSSL_GROUP ,
1139+ "SSL library doesn't support getting selected group" )
1140+ def test_no_session_group_does_not_crash (self ):
1141+ # Ensure that .group() does not crash because of OpenSSL itself.
1142+ # See https://github.com/python/cpython/issues/155782.
1143+ ctx = ssl .create_default_context ()
1144+ ctx .check_hostname = False
1145+ obj = ctx .wrap_bio (ssl .MemoryBIO (), ssl .MemoryBIO ())
1146+ self .assertIsNone (obj .group ())
1147+
11381148 def test_options (self ):
11391149 # Test default SSLContext options
11401150 ctx = ssl .SSLContext (ssl .PROTOCOL_TLS_CLIENT )
Original file line number Diff line number Diff line change 1+ :mod: `ssl `: prevent a crash in :meth: `~ssl.SSLSocket.group `
2+ for session-less objects on OpenSSL 3.2 and later. Patch by Bénédikt Tran.
Original file line number Diff line number Diff line change @@ -2197,7 +2197,9 @@ _ssl__SSLSocket_group_impl(PySSLSocket *self)
21972197#if OPENSSL_VERSION_NUMBER >= 0x30200000L
21982198 const char * group_name ;
21992199
2200- if (self -> ssl == NULL ) {
2200+ // OpenSSL issue: SSL_get0_group_name(...) crashes if no session exists.
2201+ // See https://github.com/openssl/openssl/issues/32379.
2202+ if (self -> ssl == NULL || SSL_get_session (self -> ssl ) == NULL ) {
22012203 Py_RETURN_NONE ;
22022204 }
22032205 group_name = SSL_get0_group_name (self -> ssl );
You can’t perform that action at this time.
0 commit comments