Skip to content

Commit

Permalink
Uniformize to faillible new_with_extra_roots everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
stormshield-gt authored and cpu committed Sep 18, 2024
1 parent f864c1e commit 8fcf780
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions rustls-platform-verifier/src/tests/verification_mock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ pub(super) fn verification_without_mock_root() {
.iter()
.cloned()
.collect(),
);
)
.unwrap();

#[cfg(not(target_os = "freebsd"))]
let verifier = Verifier::new();
Expand Down Expand Up @@ -337,7 +338,7 @@ fn test_with_mock_root<E: std::error::Error + PartialEq + 'static>(
let verifier = match root_src {
Roots::OnlyExtra => Verifier::new_with_fake_root(ROOT1), // TODO: time
#[cfg(not(target_os = "android"))]
Roots::ExtraAndPlatform => Verifier::new_with_extra_roots(vec![ROOT1.into()]),
Roots::ExtraAndPlatform => Verifier::new_with_extra_roots(vec![ROOT1.into()]).unwrap(),
};
let mut chain = test_case
.chain
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ fn real_world_test<E: std::error::Error>(test_case: &TestCase<E>) {
.iter()
.cloned()
.collect(),
);
)
.unwrap();

#[cfg(not(target_os = "freebsd"))]
let verifier = Verifier::new();
Expand Down
8 changes: 5 additions & 3 deletions rustls-platform-verifier/src/verification/others.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ impl Verifier {
/// Creates a new verifier whose certificate validation is provided by
/// WebPKI, using root certificates provided by the platform and augmented by
/// the provided extra root certificates.
pub fn new_with_extra_roots(roots: Vec<pki_types::CertificateDer<'static>>) -> Self {
Self {
pub fn new_with_extra_roots(
roots: Vec<pki_types::CertificateDer<'static>>,
) -> Result<Self, TlsError> {
Ok(Self {
inner: OnceCell::new(),
extra_roots: roots
.into_iter()
Expand All @@ -66,7 +68,7 @@ impl Verifier {
#[cfg(any(test, feature = "ffi-testing", feature = "dbg"))]
test_only_root_ca_override: None,
crypto_provider: OnceCell::new(),
}
})
}

/// Creates a test-only TLS certificate verifier which trusts our fake root CA cert.
Expand Down

0 comments on commit 8fcf780

Please sign in to comment.