File tree 1 file changed +18
-0
lines changed
rustls-platform-verifier/src
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,24 @@ pub fn tls_config() -> ClientConfig {
65
65
. with_no_client_auth ( )
66
66
}
67
67
68
+ /// Attempts to construct a `rustls` configuration that verifies TLS certificates in the best way
69
+ /// for the underlying OS platform, using the provided
70
+ /// [`CryptoProvider`][rustls:crypto::CryptoProvider].
71
+ ///
72
+ /// # Errors
73
+ ///
74
+ /// Propagates any error returned by [`rustls::ConfigBuilder::with_safe_default_protocol_versions`]
75
+ #[ cfg( any( target_os = "macos" , target_os = "ios" , target_os = "android" , windows) ) ]
76
+ pub fn tls_config_with_provider (
77
+ provider : Arc < rustls:: crypto:: CryptoProvider > ,
78
+ ) -> Result < ClientConfig , rustls:: Error > {
79
+ Ok ( ClientConfig :: builder_with_provider ( provider. clone ( ) )
80
+ . with_safe_default_protocol_versions ( ) ?
81
+ . dangerous ( )
82
+ . with_custom_certificate_verifier ( Arc :: new ( Verifier :: new ( ) . with_provider ( provider) ) )
83
+ . with_no_client_auth ( ) )
84
+ }
85
+
68
86
/// Exposed for debugging certificate issues with standalone tools.
69
87
///
70
88
/// This is not intended for production use, you should use [tls_config] instead.
You can’t perform that action at this time.
0 commit comments