Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4d58a1d

Browse filesBrowse files
miss-islingtonpablogsalYhg1sambvserhiy-storchaka
authored
[3.8] gh-107077: Raise SSLCertVerificationError even if the error is set via SSL_ERROR_SYSCALL (GH-107586) (GH-107591)
(cherry picked from commit 77e0919) Co-authored-by: Pablo Galindo Salgado <Pablogsal@gmail.com> Co-authored-by: T. Wouters <thomas@python.org> Co-authored-by: Łukasz Langa <lukasz@langa.pl> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
1 parent 8c6f277 commit 4d58a1d
Copy full SHA for 4d58a1d

File tree

2 files changed

+10
-0
lines changed
Filter options

2 files changed

+10
-0
lines changed
+6Lines 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

Copy file name to clipboardExpand all lines: Modules/_ssl.c
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,10 @@ PySSL_SetError(PySSLSocket *sslsock, int ret, const char *filename, int lineno)
819819
errstr = "Some I/O error occurred";
820820
}
821821
} else {
822+
if (ERR_GET_LIB(e) == ERR_LIB_SSL &&
823+
ERR_GET_REASON(e) == SSL_R_CERTIFICATE_VERIFY_FAILED) {
824+
type = PySSLCertVerificationErrorObject;
825+
}
822826
p = PY_SSL_ERROR_SYSCALL;
823827
}
824828
break;

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.