Skip to content

Commit

Permalink
[3.11] gh-107077: Raise SSLCertVerificationError even if the error is…
Browse files Browse the repository at this point in the history
… set via SSL_ERROR_SYSCALL (GH-107586) (#107588)

Co-authored-by: Pablo Galindo Salgado <[email protected]>
Co-authored-by: T. Wouters <[email protected]>
  • Loading branch information
3 people authored Aug 3, 2023
1 parent 623b0d9 commit 4f65f03
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Seems that in some conditions, OpenSSL will return ``SSL_ERROR_SYSCALL``
instead of ``SSL_ERROR_SSL`` when a certification verification has failed,
but the error parameters will still contain ``ERR_LIB_SSL`` and
``SSL_R_CERTIFICATE_VERIFY_FAILED``. We are now detecting this situation and
raising the appropiate ``ssl.SSLCertVerificationError``. Patch by Pablo
Galindo
4 changes: 4 additions & 0 deletions Modules/_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,10 @@ PySSL_SetError(PySSLSocket *sslsock, int ret, const char *filename, int lineno)
errstr = "Some I/O error occurred";
}
} else {
if (ERR_GET_LIB(e) == ERR_LIB_SSL &&
ERR_GET_REASON(e) == SSL_R_CERTIFICATE_VERIFY_FAILED) {
type = state->PySSLCertVerificationErrorObject;
}
p = PY_SSL_ERROR_SYSCALL;
}
break;
Expand Down

0 comments on commit 4f65f03

Please sign in to comment.