1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:17:36 +00:00

LibTLS: Simplify the way verify_chain is called

The `build_rsa_pre_master_secret` function originally called
`verify_chain_and_get_matching_certificate`, which verified the chain
and returned a certificate matching the specified hostname.

Since the first certificate in the chain should always be the one
matching with the hostname, we can simply use that one instead. This
means we can completely remove this method and just use `verify_chain`.

To make sure the hostname is still verified, `verify_chain` now also
checks that the first certificate in the chain matches the specified
hostname. If the hostname is empty, we currently fail the verification,
however this basically never happen, as the server name indication
extension is always used.
This commit is contained in:
Michiel Visser 2022-03-15 19:16:44 +01:00 committed by Ali Mohammad Pur
parent f8ce0eb648
commit d78813d902
3 changed files with 47 additions and 58 deletions

View file

@ -261,7 +261,7 @@ struct Options {
};
struct Context {
bool verify_chain() const;
bool verify_chain(StringView host) const;
bool verify_certificate_pair(Certificate& subject, Certificate& issuer) const;
Options options;
@ -561,8 +561,6 @@ private:
bool compute_master_secret_from_pre_master_secret(size_t length);
Optional<size_t> verify_chain_and_get_matching_certificate(StringView host) const;
void try_disambiguate_error() const;
bool m_eof { false };