0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-08 07:16:56 -05:00

fix(cli): Fix panic in load_native_certs (#27863)

Fixes https://github.com/denoland/deno/issues/27528

Can't really trigger the panic myself hence no test.
This commit is contained in:
Divy Srivastava 2025-01-31 18:29:37 +05:30 committed by GitHub
parent 1cecc0a8b0
commit b8a878cfc2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -60,6 +60,8 @@ pub enum RootCertStoreLoadError {
FailedAddPemFile(String),
#[error("Failed opening CA file: {0}")]
CaFileOpenError(String),
#[error("Failed to load platform certificates: {0}")]
FailedNativeCerts(String),
}
/// Create and populate a root cert store based on the passed options and
@ -89,7 +91,9 @@ pub fn get_root_cert_store(
root_cert_store.extend(webpki_roots::TLS_SERVER_ROOTS.to_vec());
}
"system" => {
let roots = load_native_certs().expect("could not load platform certs");
let roots = load_native_certs().map_err(|err| {
RootCertStoreLoadError::FailedNativeCerts(err.to_string())
})?;
for root in roots {
if let Err(err) = root_cert_store
.add(rustls::pki_types::CertificateDer::from(root.0.clone()))