File tree 1 file changed +14
-3
lines changed
1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -924,12 +924,23 @@ impl SslContextBuilder {
924
924
/// The file should contain a sequence of PEM-formatted CA certificates.
925
925
#[ corresponds( SSL_CTX_load_verify_locations ) ]
926
926
pub fn set_ca_file < P : AsRef < Path > > ( & mut self , file : P ) -> Result < ( ) , ErrorStack > {
927
- let file = CString :: new ( file. as_ref ( ) . as_os_str ( ) . to_str ( ) . unwrap ( ) ) . unwrap ( ) ;
927
+ self . load_verify_locations ( Some ( file. as_ref ( ) ) , None )
928
+ }
929
+
930
+ /// Loads trusted root certificates from a file and/or a directory.
931
+ #[ corresponds( SSL_CTX_load_verify_locations ) ]
932
+ pub fn load_verify_locations (
933
+ & mut self ,
934
+ ca_file : Option < & Path > ,
935
+ ca_path : Option < & Path > ,
936
+ ) -> Result < ( ) , ErrorStack > {
937
+ let ca_file = ca_file. map ( |p| CString :: new ( p. as_os_str ( ) . to_str ( ) . unwrap ( ) ) . unwrap ( ) ) ;
938
+ let ca_path = ca_path. map ( |p| CString :: new ( p. as_os_str ( ) . to_str ( ) . unwrap ( ) ) . unwrap ( ) ) ;
928
939
unsafe {
929
940
cvt ( ffi:: SSL_CTX_load_verify_locations (
930
941
self . as_ptr ( ) ,
931
- file . as_ptr ( ) as * const _ ,
932
- ptr:: null ( ) ,
942
+ ca_file . as_ref ( ) . map_or ( ptr :: null ( ) , |s| s . as_ptr ( ) ) ,
943
+ ca_path . as_ref ( ) . map_or ( ptr:: null ( ) , |s| s . as_ptr ( ) ) ,
933
944
) )
934
945
. map ( |_| ( ) )
935
946
}
You can’t perform that action at this time.
0 commit comments