File tree Expand file tree Collapse file tree 5 files changed +13
-21
lines changed
rustls-platform-verifier/src Expand file tree Collapse file tree 5 files changed +13
-21
lines changed Original file line number Diff line number Diff line change @@ -111,13 +111,9 @@ pub(super) fn verification_without_mock_root() {
111
111
// runner fails to find any roots with openssl-probe we need to provide webpki-root-certs here
112
112
// or the test will fail with the `OtherError` instead of the expected `CertificateError`.
113
113
#[ cfg( target_os = "freebsd" ) ]
114
- let verifier = Verifier :: new_with_extra_roots (
115
- webpki_root_certs:: TLS_SERVER_ROOT_CERTS
116
- . iter ( )
117
- . cloned ( )
118
- . collect ( ) ,
119
- )
120
- . unwrap ( ) ;
114
+ let verifier =
115
+ Verifier :: new_with_extra_roots ( webpki_root_certs:: TLS_SERVER_ROOT_CERTS . iter ( ) . cloned ( ) )
116
+ . unwrap ( ) ;
121
117
122
118
#[ cfg( not( target_os = "freebsd" ) ) ]
123
119
let verifier = Verifier :: new ( ) ;
@@ -338,7 +334,7 @@ fn test_with_mock_root<E: std::error::Error + PartialEq + 'static>(
338
334
let verifier = match root_src {
339
335
Roots :: OnlyExtra => Verifier :: new_with_fake_root ( ROOT1 ) , // TODO: time
340
336
#[ cfg( not( target_os = "android" ) ) ]
341
- Roots :: ExtraAndPlatform => Verifier :: new_with_extra_roots ( vec ! [ ROOT1 . into( ) ] ) . unwrap ( ) ,
337
+ Roots :: ExtraAndPlatform => Verifier :: new_with_extra_roots ( [ ROOT1 . into ( ) ] ) . unwrap ( ) ,
342
338
} ;
343
339
let mut chain = test_case
344
340
. chain
Original file line number Diff line number Diff line change @@ -128,13 +128,9 @@ fn real_world_test<E: std::error::Error>(test_case: &TestCase<E>) {
128
128
// On BSD systems openssl-probe fails to find the system CA bundle,
129
129
// so we must provide extra roots from webpki-root-cert.
130
130
#[ cfg( target_os = "freebsd" ) ]
131
- let verifier = Verifier :: new_with_extra_roots (
132
- webpki_root_certs:: TLS_SERVER_ROOT_CERTS
133
- . iter ( )
134
- . cloned ( )
135
- . collect ( ) ,
136
- )
137
- . unwrap ( ) ;
131
+ let verifier =
132
+ Verifier :: new_with_extra_roots ( webpki_root_certs:: TLS_SERVER_ROOT_CERTS . iter ( ) . cloned ( ) )
133
+ . unwrap ( ) ;
138
134
139
135
#[ cfg( not( target_os = "freebsd" ) ) ]
140
136
let verifier = Verifier :: new ( ) ;
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ impl Verifier {
73
73
///
74
74
/// See [Verifier::new] for the external requirements the verifier needs.
75
75
pub fn new_with_extra_roots (
76
- roots : Vec < pki_types:: CertificateDer < ' static > > ,
76
+ roots : impl IntoIterator < Item = pki_types:: CertificateDer < ' static > > ,
77
77
) -> Result < Self , TlsError > {
78
78
let extra_roots = roots
79
79
. into_iter ( )
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ impl Verifier {
54
54
/// WebPKI, using root certificates provided by the platform and augmented by
55
55
/// the provided extra root certificates.
56
56
pub fn new_with_extra_roots (
57
- roots : Vec < pki_types:: CertificateDer < ' static > > ,
57
+ roots : impl IntoIterator < Item = pki_types:: CertificateDer < ' static > > ,
58
58
) -> Result < Self , TlsError > {
59
59
Ok ( Self {
60
60
inner : OnceCell :: new ( ) ,
Original file line number Diff line number Diff line change @@ -219,11 +219,11 @@ struct CertEngine {
219
219
220
220
impl CertEngine {
221
221
fn new_with_extra_roots (
222
- roots : & [ pki_types:: CertificateDer < ' static > ] ,
222
+ roots : impl IntoIterator < Item = pki_types:: CertificateDer < ' static > > ,
223
223
) -> Result < Self , TlsError > {
224
224
let mut exclusive_store = CertificateStore :: new ( ) ?;
225
225
for root in roots {
226
- exclusive_store. add_cert ( root) ?;
226
+ exclusive_store. add_cert ( & root) ?;
227
227
}
228
228
229
229
let mut config = CERT_CHAIN_ENGINE_CONFIG :: zeroed_with_size ( ) ;
@@ -516,9 +516,9 @@ impl Verifier {
516
516
/// [`set_provider`][Verifier::set_provider]/[`with_provider`][Verifier::with_provider] or
517
517
/// [`CryptoProvider::install_default`] before the verifier can be used.
518
518
pub fn new_with_extra_roots (
519
- roots : Vec < pki_types:: CertificateDer < ' static > > ,
519
+ roots : impl IntoIterator < Item = pki_types:: CertificateDer < ' static > > ,
520
520
) -> Result < Self , TlsError > {
521
- let cert_engine = CertEngine :: new_with_extra_roots ( & roots) ?;
521
+ let cert_engine = CertEngine :: new_with_extra_roots ( roots) ?;
522
522
Ok ( Self {
523
523
#[ cfg( any( test, feature = "ffi-testing" , feature = "dbg" ) ) ]
524
524
test_only_root_ca_override : None ,
You can’t perform that action at this time.
0 commit comments