Skip to content

Commit ddcaa3e

Browse files
Uniformize to faillible new_with_extra_roots everywhere
1 parent 05ddb1c commit ddcaa3e

File tree

3 files changed

+10
-6
lines changed
  • rustls-platform-verifier/src

3 files changed

+10
-6
lines changed

rustls-platform-verifier/src/tests/verification_mock/mod.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ pub(super) fn verification_without_mock_root() {
116116
.iter()
117117
.cloned()
118118
.collect(),
119-
);
119+
)
120+
.unwrap();
120121

121122
#[cfg(not(target_os = "freebsd"))]
122123
let verifier = Verifier::new();
@@ -337,7 +338,7 @@ fn test_with_mock_root<E: std::error::Error + PartialEq + 'static>(
337338
let verifier = match root_src {
338339
Roots::OnlyExtra => Verifier::new_with_fake_root(ROOT1), // TODO: time
339340
#[cfg(not(target_os = "android"))]
340-
Roots::ExtraAndPlatform => Verifier::new_with_extra_roots(vec![ROOT1.into()]),
341+
Roots::ExtraAndPlatform => Verifier::new_with_extra_roots(vec![ROOT1.into()]).unwrap(),
341342
};
342343
let mut chain = test_case
343344
.chain

rustls-platform-verifier/src/tests/verification_real_world/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ fn real_world_test<E: std::error::Error>(test_case: &TestCase<E>) {
133133
.iter()
134134
.cloned()
135135
.collect(),
136-
);
136+
)
137+
.unwrap();
137138

138139
#[cfg(not(target_os = "freebsd"))]
139140
let verifier = Verifier::new();

rustls-platform-verifier/src/verification/others.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@ impl Verifier {
5353
/// Creates a new verifier whose certificate validation is provided by
5454
/// WebPKI, using root certificates provided by the platform and augmented by
5555
/// the provided extra root certificates.
56-
pub fn new_with_extra_roots(roots: Vec<pki_types::CertificateDer<'static>>) -> Self {
57-
Self {
56+
pub fn new_with_extra_roots(
57+
roots: Vec<pki_types::CertificateDer<'static>>,
58+
) -> Result<Self, TlsError> {
59+
Ok(Self {
5860
inner: OnceCell::new(),
5961
extra_roots: roots
6062
.into_iter()
@@ -66,7 +68,7 @@ impl Verifier {
6668
#[cfg(any(test, feature = "ffi-testing", feature = "dbg"))]
6769
test_only_root_ca_override: None,
6870
crypto_provider: OnceCell::new(),
69-
}
71+
})
7072
}
7173

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

0 commit comments

Comments
 (0)