fix(wolfssl): when skip_common_name is set, skip OCSP status checking, but always do SNI (IDFGH-13834) #14684
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This change includes two parts:
When server certificate common name checking is disabled, OCSP status checks should also be disabled, as they cannot succeed when server's domain name is not matching its certificate's CN. (Match application programmers expectation.)
With wolfSSL SNI should always be enabled, because wolfSSL is known to fail to handle related TLS alerts correctly when SNI is missing.
Testing
I've tested my changes with a wide coverage of different use cases performing TLS connections with the esp-http-client and esp-websocket-client libraries having wolfssl 5.7.2 (from /github.com/frankencode/esp-wolfssl) being configured as esp-tls backend and having TLS 1.3 + OCSP enabled. For a few tests I needed to disable server name checks on https connections, which I did with the esp-http-client's option skip_cert_common_name_check (which translates to skip_common_name on esp-tls layer) and this, as someone might have expected, now also disables OCSP status checks on the server's certificate. Without this change on my particular test servers I'm getting wolfSSL error -406 (invalid certificate status), which is to be expected when an OCSP status is stapled, but the server's certificate CN field is misconfigured and/or not matching its hostname. Having OCSP status checks also being disabled with the skip_common_name option meets my expectation (knowing well the security implications).
(mbedTLS still does not support OCSP stapling in any form, including a stapled status with TLS 1.3 and hence is not affected by this change.)