[WIP] WiFiClientSecure: make functions for certificate verification more consistent #3700
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.
Currently WiFiClientSecure has two ways to verify that the remote server is using an expected certificate:
verify(fingerprint, hostname)
, which compares SHA1 fingerprint of the server certificate to a known value, andsetCACert
/loadCACert
+verifyCertChain
, which checks the certificate chain, given the root certificate.This PR attempts to make all ways of verification follow the same pattern:
setCACert
,setFingerprint
,setSPKI
,allowSelfSignedCerts
)This approach makes it possible to use WiFiClientSecure methods (
setCACert
,setFingerprint
,setSPKI
,allowSelfSignedCerts
) together with HTTPClient: first call HTTPClient::begin, then set verification method on the underlying WiFiClientSecure, then call HTTPClient::GET or POST to connect and issue the request. Internally, that calls WiFiClientSecure::verifyCertChain once the connection is established.This PR also adds verification using subjectPublicKeyInfo (SPKI), which was present in axTLS-8266 for a while now. SPKI is a SHA256 hash of the public key, and it doesn't change as often as the certificates are reissued, hence may require less often updates compared to SHA1 fingerprint of the certifiacate.
Currently WIP as only WiFiClientSecure changes are in place.
begin
functions in HTTPClient, add explicit functions to use TLS support