Skip to content

Commit 0ddc1e2

Browse files
committed
Use the simpler SSL_get1_session API that CPython <=3.9 used on all recent OpenSSL versions.
1 parent 537c5bb commit 0ddc1e2

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

Modules/_ssl.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2844,15 +2844,13 @@ PySSL_get_session(PySSLSocket *self, void *closure) {
28442844
PySSLSession *pysess;
28452845
SSL_SESSION *session;
28462846

2847-
/* duplicate session as workaround for session bug in OpenSSL 1.1.0,
2848-
* https://github.com/openssl/openssl/issues/1550 */
2849-
session = SSL_get0_session(self->ssl); /* borrowed reference */
2847+
/* See discussion on https://github.com/python/cpython/pull/123249 and
2848+
* older discussion on https://github.com/openssl/openssl/issues/1550.
2849+
* CPython is NOT doing the right thing here. */
2850+
session = SSL_get1_session(self->ssl);
28502851
if (session == NULL) {
28512852
Py_RETURN_NONE;
28522853
}
2853-
if ((session = _ssl_session_dup(session)) == NULL) {
2854-
return NULL;
2855-
}
28562854
pysess = PyObject_GC_New(PySSLSession, self->ctx->state->PySSLSession_Type);
28572855
if (pysess == NULL) {
28582856
SSL_SESSION_free(session);

0 commit comments

Comments
 (0)