When wpa_supplicant is configured to use EAP authentication with
ca_cert="hash://server/sha256/<hex>", the connection is set to
server_cert_only mode. In this mode, all leaf certificate validation
errors are currently ignored if the hash matches. This behavior was
introduced in commit
00033a0903f6 ("OpenSSL: Always accept pinned
certificates") to ignore chain validation problems [1], but it also
unintentionally ignores expiry and not-yet-valid errors on the leaf
certificate.
This patch changes the validation logic under servert_cert_only mode so
that expiry (X509_V_ERR_CERT_HAS_EXPIRED) and not-yet-valid
(X509_V_ERR_CERT_NOT_YET_VALID) errors are not ignored, while other
validation errors continue to be bypassed if the hash matches. If expiry
checks must be disabled, the existing tls_disable_time_checks option can
still be used.
[1] https://lists.infradead.org/pipermail/hostap/2015-March/032240.html
Signed-off-by: Rathan Appana <rathanappana@gmail.com>
err_str = "Server certificate mismatch";
err = X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN;
preverify_ok = 0;
- } else if (!preverify_ok) {
+ } else if (!preverify_ok &&
+ err != X509_V_ERR_CERT_HAS_EXPIRED &&
+ err != X509_V_ERR_CERT_NOT_YET_VALID) {
/*
* Certificate matches pinned certificate, allow
* regardless of other problems.