File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1097,6 +1097,15 @@ def test_set_server_sigalgs(self):
10971097 if CAN_IGNORE_UNKNOWN_OPENSSL_SIGALGS :
10981098 self .assertIsNone (ctx .set_server_sigalgs ('rsa_pss_rsae_sha256:?foo' ))
10991099
1100+ @unittest .skipUnless (CAN_GET_SELECTED_OPENSSL_GROUP ,
1101+ "SSL library doesn't support getting selected group" )
1102+ def test_no_session_group_does_not_crash (self ):
1103+ # Ensure that .group() does not crash because of OpenSSL itself.
1104+ # See https://github.com/python/cpython/issues/155782.
1105+ ctx = ssl .create_default_context ()
1106+ obj = ctx .wrap_bio (ssl .MemoryBIO (), ssl .MemoryBIO ())
1107+ self .assertIsNone (obj .group ())
1108+
11001109 def test_options (self ):
11011110 # Test default SSLContext options
11021111 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: `SSLObject.group <ssl.SSLObject.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 @@ -2224,7 +2224,9 @@ _ssl__SSLSocket_group_impl(PySSLSocket *self)
22242224#if OPENSSL_VERSION_NUMBER >= 0x30200000L
22252225 const char * group_name ;
22262226
2227- if (self -> ssl == NULL ) {
2227+ // OpenSSL issue: SSL_get0_group_name(...) crashes if no session exists.
2228+ // See https://github.com/openssl/openssl/issues/32379.
2229+ if (self -> ssl == NULL || SSL_get_session (self -> ssl ) == NULL ) {
22282230 Py_RETURN_NONE ;
22292231 }
22302232 group_name = SSL_get0_group_name (self -> ssl );
You can’t perform that action at this time.
0 commit comments