From 8e6b06b89d47c0ce27c2f959be6d8d48ffab5ebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Thu, 1 Aug 2024 13:33:31 +0100 Subject: fix: Don't panic if failed to add system certificate (#24823) This commit fixes the panic from https://github.com/denoland/deno/issues/24137. I'm not sure if we want to hard error or maybe instead skip with a warning and continue execution. --- cli/args/mod.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'cli') diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 7ae003111..3d35d8c36 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -624,6 +624,8 @@ pub enum RootCertStoreLoadError { UnknownStore(String), #[error("Unable to add pem file to certificate store: {0}")] FailedAddPemFile(String), + #[error("Unable to add system certificate to certificate store: {0}")] + FailedAddSystemCert(String), #[error("Failed opening CA file: {0}")] CaFileOpenError(String), } @@ -659,7 +661,9 @@ pub fn get_root_cert_store( for root in roots { root_cert_store .add(rustls::pki_types::CertificateDer::from(root.0)) - .expect("Failed to add platform cert to root cert store"); + .map_err(|e| { + RootCertStoreLoadError::FailedAddSystemCert(e.to_string()) + })?; } } _ => { -- cgit v1.2.3