mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-30 06:06:48 +00:00
LibCrypto: Return PEM type when decoding and sanity check footer
Improve PEM decoding by parsing the header and returning it along the data. Also verify if the header is equal to the footer.
This commit is contained in:
parent
0280838944
commit
57ecd72256
Notes:
github-actions[bot]
2024-11-30 10:18:56 +00:00
Author: https://github.com/devgianlu
Commit: 57ecd72256
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2648
4 changed files with 75 additions and 20 deletions
|
@ -501,12 +501,12 @@ Vector<Certificate> TLSv12::parse_pem_certificate(ReadonlyBytes certificate_pem_
|
|||
}
|
||||
|
||||
auto decoded_certificate = Crypto::decode_pem(certificate_pem_buffer);
|
||||
if (decoded_certificate.is_empty()) {
|
||||
if (decoded_certificate.type != Crypto::PEMType::Certificate) {
|
||||
dbgln("Certificate not PEM");
|
||||
return {};
|
||||
}
|
||||
|
||||
auto maybe_certificate = Certificate::parse_certificate(decoded_certificate);
|
||||
auto maybe_certificate = Certificate::parse_certificate(decoded_certificate.data);
|
||||
if (!maybe_certificate.is_error()) {
|
||||
dbgln("Invalid certificate");
|
||||
return {};
|
||||
|
@ -576,7 +576,7 @@ ErrorOr<Vector<Certificate>> DefaultRootCACertificates::parse_pem_root_certifica
|
|||
auto certs = TRY(Crypto::decode_pems(data));
|
||||
|
||||
for (auto& cert : certs) {
|
||||
auto certificate_result = Certificate::parse_certificate(cert.bytes());
|
||||
auto certificate_result = Certificate::parse_certificate(cert.data);
|
||||
if (certificate_result.is_error()) {
|
||||
// FIXME: It would be nice to have more informations about the certificate we failed to parse.
|
||||
// Like: Issuer, Algorithm, CN, etc
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue