Skip to content

Commit 24d54fe

Browse files
miss-islingtonpablogsalYhg1s
authored
[3.10] gh-107077: Raise SSLCertVerificationError even if the error is set via SSL_ERROR_SYSCALL (GH-107586) (#107589)
Co-authored-by: Pablo Galindo Salgado <[email protected]> Co-authored-by: T. Wouters <[email protected]>
1 parent a9e5e59 commit 24d54fe

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Seems that in some conditions, OpenSSL will return ``SSL_ERROR_SYSCALL``
2+
instead of ``SSL_ERROR_SSL`` when a certification verification has failed,
3+
but the error parameters will still contain ``ERR_LIB_SSL`` and
4+
``SSL_R_CERTIFICATE_VERIFY_FAILED``. We are now detecting this situation and
5+
raising the appropiate ``ssl.SSLCertVerificationError``. Patch by Pablo
6+
Galindo

Modules/_ssl.c

+4
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,10 @@ PySSL_SetError(PySSLSocket *sslsock, int ret, const char *filename, int lineno)
656656
errstr = "Some I/O error occurred";
657657
}
658658
} else {
659+
if (ERR_GET_LIB(e) == ERR_LIB_SSL &&
660+
ERR_GET_REASON(e) == SSL_R_CERTIFICATE_VERIFY_FAILED) {
661+
type = state->PySSLCertVerificationErrorObject;
662+
}
659663
p = PY_SSL_ERROR_SYSCALL;
660664
}
661665
break;

0 commit comments

Comments
 (0)