File tree Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change 1- use std:: { pin:: Pin , sync :: Once } ;
1+ use std:: pin:: Pin ;
22
33use openssl:: {
44 error:: ErrorStack ,
@@ -45,8 +45,6 @@ pub(super) async fn tls_connect(
4545 tcp_stream : TcpStream ,
4646 cfg : & TlsConfig ,
4747) -> Result < TlsStream > {
48- init_trust ( ) ;
49-
5048 let mut stream = make_ssl_stream ( host, tcp_stream, cfg) . map_err ( |err| {
5149 Error :: from ( ErrorKind :: InvalidTlsConfig {
5250 message : err. to_string ( ) ,
@@ -71,6 +69,11 @@ fn make_openssl_connector(cfg: TlsOptions) -> Result<SslConnector> {
7169
7270 let mut builder = SslConnector :: builder ( SslMethod :: tls_client ( ) ) . map_err ( openssl_err) ?;
7371
72+ let probe = openssl_probe:: probe ( ) ;
73+ builder
74+ . load_verify_locations ( probe. cert_file . as_deref ( ) , probe. cert_dir . as_deref ( ) )
75+ . map_err ( openssl_err) ?;
76+
7477 let TlsOptions {
7578 allow_invalid_certificates,
7679 ca_file_path,
@@ -111,15 +114,6 @@ fn make_openssl_connector(cfg: TlsOptions) -> Result<SslConnector> {
111114 Ok ( builder. build ( ) )
112115}
113116
114- fn init_trust ( ) {
115- static ONCE : Once = Once :: new ( ) ;
116- // nosemgrep: unsafe-usage
117- ONCE . call_once ( || unsafe {
118- // mongodb rating: No Fix Needed
119- openssl_probe:: init_openssl_env_vars ( )
120- } )
121- }
122-
123117fn make_ssl_stream (
124118 host : & str ,
125119 tcp_stream : TcpStream ,
You can’t perform that action at this time.
0 commit comments