Skip to content

Commit

Permalink
gh-107077: Raise SSLCertVerificationError even if the error is set vi…
Browse files Browse the repository at this point in the history
…a SSL_ERROR_SYSCALL (GH-107586)

(cherry picked from commit 77e0919)

Co-authored-by: Pablo Galindo Salgado <[email protected]>
Co-authored-by: T. Wouters <[email protected]>
  • Loading branch information
2 people authored and miss-islington committed Aug 3, 2023
1 parent 38b489b commit b0b34a0
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 @@ -817,6 +817,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 b0b34a0

Please sign in to comment.