@@ -11,12 +11,16 @@ use self::openssl::ssl::{
11
11
SslVerifyMode ,
12
12
} ;
13
13
use self :: openssl:: x509:: { store:: X509StoreBuilder , X509VerifyResult , X509 } ;
14
+ use self :: openssl_probe:: ProbeResult ;
14
15
use std:: error;
15
16
use std:: fmt;
16
17
use std:: io;
18
+ use std:: sync:: LazyLock ;
17
19
18
20
use { Protocol , TlsAcceptorBuilder , TlsConnectorBuilder } ;
19
21
22
+ static PROBE_RESULT : LazyLock < ProbeResult > = LazyLock :: new ( openssl_probe:: probe) ;
23
+
20
24
#[ cfg( have_min_max_version) ]
21
25
fn supported_protocols (
22
26
min : Option < Protocol > ,
@@ -268,8 +272,17 @@ impl TlsConnector {
268
272
pub fn new ( builder : & TlsConnectorBuilder ) -> Result < TlsConnector , Error > {
269
273
let mut connector = SslConnector :: builder ( SslMethod :: tls ( ) ) ?;
270
274
271
- let probe = openssl_probe:: probe ( ) ;
272
- connector. load_verify_locations ( probe. cert_file . as_deref ( ) , probe. cert_dir . as_deref ( ) ) ?;
275
+ // We need to load these separately so an error on one doesn't prevent the other from loading.
276
+ if let Some ( cert_file) = & PROBE_RESULT . cert_file {
277
+ if let Err ( e) = connector. load_verify_locations ( Some ( cert_file) , None ) {
278
+ debug ! ( "load_verify_locations cert file error: {:?}" , e) ;
279
+ }
280
+ }
281
+ if let Some ( cert_dir) = & PROBE_RESULT . cert_dir {
282
+ if let Err ( e) = connector. load_verify_locations ( None , Some ( cert_dir) ) {
283
+ debug ! ( "load_verify_locations cert dir error: {:?}" , e) ;
284
+ }
285
+ }
273
286
274
287
if let Some ( ref identity) = builder. identity {
275
288
connector. set_certificate ( & identity. 0 . cert ) ?;
0 commit comments