Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0915360

Browse files
authored
bpo-28182: restore backwards compatibility (#3464)
b3ad0e5 broke backwards compatibility with OpenSSL < 1.0.2. Signed-off-by: Christian Heimes <[email protected]>
1 parent db610e9 commit 0915360

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Modules/_ssl.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,18 +485,23 @@ fill_and_set_sslerror(PySSLSocket *sslsock, PyObject *type, int ssl_errno,
485485
}
486486

487487
switch (verify_code) {
488+
#ifdef X509_V_ERR_HOSTNAME_MISMATCH
489+
/* OpenSSL >= 1.0.2, LibreSSL >= 2.5.3 */
488490
case X509_V_ERR_HOSTNAME_MISMATCH:
489491
verify_obj = PyUnicode_FromFormat(
490492
"Hostname mismatch, certificate is not valid for '%S'.",
491493
sslsock->server_hostname
492494
);
493495
break;
496+
#endif
497+
#ifdef X509_V_ERR_IP_ADDRESS_MISMATCH
494498
case X509_V_ERR_IP_ADDRESS_MISMATCH:
495499
verify_obj = PyUnicode_FromFormat(
496500
"IP address mismatch, certificate is not valid for '%S'.",
497501
sslsock->server_hostname
498502
);
499503
break;
504+
#endif
500505
default:
501506
verify_str = X509_verify_cert_error_string(verify_code);
502507
if (verify_str != NULL) {

0 commit comments

Comments
 (0)