Add option to disable hostname check (#399)

* Suppress compiler warnings about unused elements.

* Enable CMake's compilation database.

* Add TLS option to disable checking a certificate's host name.

* Add `--disable-hostname-validation` to `ws`.

* Add test for disabling hostname validation.
This commit is contained in:
Robin Sommer
2022-10-12 15:41:32 +02:00
committed by GitHub
parent 0b8b5608dc
commit 1e46466114
10 changed files with 126 additions and 34 deletions

View File

@ -48,7 +48,7 @@ namespace ix
mbedtls_pk_init(&_pkey);
}
bool SocketMbedTLS::loadSystemCertificates(std::string& errorMsg)
bool SocketMbedTLS::loadSystemCertificates(std::string& /* errorMsg */)
{
#ifdef _WIN32
DWORD flags = CERT_STORE_READONLY_FLAG | CERT_STORE_OPEN_EXISTING_FLAG |
@ -195,10 +195,13 @@ namespace ix
return false;
}
if (!host.empty() && mbedtls_ssl_set_hostname(&_ssl, host.c_str()) != 0)
if (!_tlsOptions.disable_hostname_validation)
{
errMsg = "SNI setup failed";
return false;
if (!host.empty() && mbedtls_ssl_set_hostname(&_ssl, host.c_str()) != 0)
{
errMsg = "SNI setup failed";
return false;
}
}
return true;