File tree Expand file tree Collapse file tree 4 files changed +27
-5
lines changed Expand file tree Collapse file tree 4 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ const ENTRYPOINTS: &[&str] = &[
96
96
"SSL_CTX_set_alpn_protos" ,
97
97
"SSL_CTX_set_alpn_select_cb" ,
98
98
"SSL_CTX_set_cert_cb" ,
99
+ "SSL_CTX_set_cert_store" ,
99
100
"SSL_CTX_set_cipher_list" ,
100
101
"SSL_CTX_set_ciphersuites" ,
101
102
"SSL_CTX_set_client_CA_list" ,
Original file line number Diff line number Diff line change @@ -297,6 +297,12 @@ entry! {
297
297
}
298
298
}
299
299
300
+ entry ! {
301
+ pub fn _SSL_CTX_set_cert_store( ctx: * mut SSL_CTX , store: * mut X509_STORE ) {
302
+ try_clone_arc!( ctx) . get_mut( ) . set_x509_store( store) ;
303
+ }
304
+ }
305
+
300
306
fn load_verify_files (
301
307
ctx : & NotThreadSafe < SSL_CTX > ,
302
308
file_names : impl Iterator < Item = PathBuf > ,
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ use rustls::{
21
21
} ;
22
22
23
23
use not_thread_safe:: NotThreadSafe ;
24
+ use x509:: OwnedX509Store ;
24
25
25
26
mod bio;
26
27
mod cache;
@@ -435,7 +436,7 @@ impl SslContext {
435
436
verify_mode : VerifyMode :: default ( ) ,
436
437
verify_depth : -1 ,
437
438
verify_roots : RootCertStore :: empty ( ) ,
438
- verify_x509_store : x509 :: OwnedX509Store :: new ( ) ,
439
+ verify_x509_store : OwnedX509Store :: default ( ) ,
439
440
alpn : vec ! [ ] ,
440
441
default_cert_file : None ,
441
442
default_cert_dir : None ,
@@ -615,6 +616,13 @@ impl SslContext {
615
616
self . verify_x509_store . pointer ( )
616
617
}
617
618
619
+ fn set_x509_store ( & mut self , store : * mut X509_STORE ) {
620
+ if store. is_null ( ) {
621
+ return ;
622
+ }
623
+ self . verify_x509_store = OwnedX509Store :: new ( store) ;
624
+ }
625
+
618
626
fn set_alpn_offer ( & mut self , alpn : Vec < Vec < u8 > > ) {
619
627
self . alpn = alpn;
620
628
}
Original file line number Diff line number Diff line change @@ -237,17 +237,24 @@ pub struct OwnedX509Store {
237
237
}
238
238
239
239
impl OwnedX509Store {
240
- pub fn new ( ) -> Self {
241
- Self {
242
- raw : unsafe { X509_STORE_new ( ) } ,
243
- }
240
+ /// Create a new one, from a (donated) existing ref.
241
+ pub fn new ( store : * mut X509_STORE ) -> Self {
242
+ Self { raw : store }
244
243
}
245
244
246
245
pub fn pointer ( & self ) -> * mut X509_STORE {
247
246
self . raw
248
247
}
249
248
}
250
249
250
+ impl Default for OwnedX509Store {
251
+ fn default ( ) -> Self {
252
+ Self {
253
+ raw : unsafe { X509_STORE_new ( ) } ,
254
+ }
255
+ }
256
+ }
257
+
251
258
impl Drop for OwnedX509Store {
252
259
fn drop ( & mut self ) {
253
260
unsafe {
You can’t perform that action at this time.
0 commit comments