From 0b9fadf81fae1adaefa925c49c8655bc40971168 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Wed, 19 Dec 2018 08:46:39 +0100 Subject: mbedtls: follow-up VERIFYHOST fix from f097669248 Fix-by: Eric Rosenquist Fixes #3376 Closes #3390 --- lib/vtls/mbedtls.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'lib/vtls') diff --git a/lib/vtls/mbedtls.c b/lib/vtls/mbedtls.c index ec1c13d95..88256a861 100644 --- a/lib/vtls/mbedtls.c +++ b/lib/vtls/mbedtls.c @@ -574,25 +574,25 @@ mbed_connect_step2(struct connectdata *conn, ret = mbedtls_ssl_get_verify_result(&BACKEND->ssl); + if(!SSL_CONN_CONFIG(verifyhost)) + /* Ignore hostname errors if verifyhost is disabled */ + ret &= ~MBEDTLS_X509_BADCERT_CN_MISMATCH; + if(ret && SSL_CONN_CONFIG(verifypeer)) { if(ret & MBEDTLS_X509_BADCERT_EXPIRED) failf(data, "Cert verify failed: BADCERT_EXPIRED"); - if(ret & MBEDTLS_X509_BADCERT_REVOKED) { + else if(ret & MBEDTLS_X509_BADCERT_REVOKED) failf(data, "Cert verify failed: BADCERT_REVOKED"); - return CURLE_PEER_FAILED_VERIFICATION; - } - if(ret & MBEDTLS_X509_BADCERT_NOT_TRUSTED) + else if(ret & MBEDTLS_X509_BADCERT_CN_MISMATCH) + failf(data, "Cert verify failed: BADCERT_CN_MISMATCH"); + + else if(ret & MBEDTLS_X509_BADCERT_NOT_TRUSTED) failf(data, "Cert verify failed: BADCERT_NOT_TRUSTED"); return CURLE_PEER_FAILED_VERIFICATION; } - if(ret && SSL_CONN_CONFIG(verifyhost)) { - if(ret & MBEDTLS_X509_BADCERT_CN_MISMATCH) - failf(data, "Cert verify failed: BADCERT_CN_MISMATCH"); - return CURLE_PEER_FAILED_VERIFICATION; - } peercert = mbedtls_ssl_get_peer_cert(&BACKEND->ssl); -- cgit v1.2.3