Skip to content

Commit 953f592

Browse files
committed
fix(tls): install IP literals via the WolfSSL verify params directly
wolfSSL_check_ip_address reports success even on builds that compiled out enforcement, so its return check could never fail closed. Setting the literal through wolfSSL_get0_param and wolfSSL_X509_VERIFY_PARAM_set1_ip_asc installs it on the exact path the certificate check consults, returns a meaningful failure, and binds symbols exported only by OPENSSL_EXTRA builds — running against a WolfSSL downgraded below the build-time feature set now fails at load instead of silently skipping the name check.
1 parent 1f2c299 commit 953f592

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

src/wolfssl/src/wolfssl_stream.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1492,17 +1492,25 @@ struct wolfssl_stream::impl
14921492
// Enforcement needs both flags: OPENSSL_EXTRA routes
14931493
// the address into the verify params that the cert
14941494
// check consults, and WOLFSSL_IP_ALT_NAME makes the
1495-
// parser record iPAddress entries at all. Without
1496-
// either, wolfSSL_check_ip_address still returns
1497-
// success and verification silently checks nothing.
1495+
// parser record iPAddress entries at all.
14981496
#if defined(OPENSSL_EXTRA) && defined(WOLFSSL_IP_ALT_NAME)
1499-
if (wolfSSL_check_ip_address(ssl_, hostname_.c_str())
1500-
!= WOLFSSL_SUCCESS)
1497+
// Install via the verify params directly, not
1498+
// wolfSSL_check_ip_address: that wrapper reports
1499+
// success even when enforcement is compiled out, and
1500+
// binding these OPENSSL_EXTRA-only symbols makes a
1501+
// run against a downgraded WolfSSL fail at load
1502+
// rather than skip the check silently.
1503+
WOLFSSL_X509_VERIFY_PARAM* vp = wolfSSL_get0_param(ssl_);
1504+
if (!vp ||
1505+
wolfSSL_X509_VERIFY_PARAM_set1_ip_asc(
1506+
vp, hostname_.c_str()) != WOLFSSL_SUCCESS)
15011507
{
1508+
// Fail closed rather than handshake without the
1509+
// requested name check.
15021510
wolfSSL_free(ssl_);
15031511
ssl_ = nullptr;
15041512
return std::make_error_code(
1505-
std::errc::function_not_supported);
1513+
std::errc::invalid_argument);
15061514
}
15071515
#else
15081516
wolfSSL_free(ssl_);

0 commit comments

Comments
 (0)