10000 gh-107077: Raise SSLCertVerificationError even if the error is set vi… · miss-islington/cpython@197a5b1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 197a5b1

Browse files
pablogsalYhg1s
authored andcommitted
pythongh-107077: Raise SSLCertVerificationError even if the error is set via SSL_ERROR_SYSCALL (pythonGH-107586)
(cherry picked from commit 77e0919) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> Co-authored-by: T. Wouters <thomas@python.org>
1 parent 12d1c49 commit 197a5b1

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
Lines changed: 6 additions & 0 deletions
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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,10 @@ PySSL_SetError(PySSLSocket *sslsock, int ret, const char *filename, int lineno)
647647
errstr = "Some I/O error occurred";
648648
}
649649
} else {
650+
if (ERR_GET_LIB(e) == ERR_LIB_SSL &&
651+
ERR_GET_REASON(e) == SSL_R_CERTIFICATE_VERIFY_FAILED) {
652+
type = state->PySSLCertVerificationErrorObject;
653+
}
650654
p = PY_SSL_ERROR_SYSCALL;
651655
}
652656
break;

0 commit comments

Comments
 (0)
0