File tree 3 files changed +34
-1
lines changed
openssl-sys/src/handwritten
3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -644,6 +644,8 @@ const_ptr_api! {
644
644
extern "C" {
645
645
#[ cfg( any( ossl110, libressl270) ) ]
646
646
pub fn X509_STORE_get0_objects ( ctx: #[ const_ptr_if( ossl300) ] X509_STORE ) -> * mut stack_st_X509_OBJECT;
647
+ #[ cfg( ossl300) ]
648
+ pub fn X509_STORE_get1_all_certs ( ctx: * mut X509_STORE ) -> * mut stack_st_X509;
647
649
}
648
650
}
649
651
Original file line number Diff line number Diff line change 42
42
//! ```
43
43
44
44
use cfg_if:: cfg_if;
45
- use foreign_types:: ForeignTypeRef ;
45
+ use foreign_types:: { ForeignType , ForeignTypeRef } ;
46
46
use std:: mem;
47
47
48
48
use crate :: error:: ErrorStack ;
49
49
#[ cfg( not( boringssl) ) ]
50
50
use crate :: ssl:: SslFiletype ;
51
+ #[ cfg( ossl300) ]
52
+ use crate :: stack:: Stack ;
51
53
use crate :: stack:: StackRef ;
52
54
#[ cfg( any( ossl102, libressl261) ) ]
53
55
use crate :: x509:: verify:: { X509VerifyFlags , X509VerifyParamRef } ;
@@ -260,10 +262,24 @@ foreign_type_and_impl_send_sync! {
260
262
261
263
impl X509StoreRef {
262
264
/// Get a reference to the cache of certificates in this store.
265
+ ///
266
+ /// This method is deprecated. It is **unsound** and will be removed in a
267
+ /// future version of rust-openssl. `X509StoreRef::all_certificates`
268
+ /// should be used instead.
269
+ #[ deprecated(
270
+ note = "This method is unsound, and will be removed in a future version of rust-openssl. X509StoreRef::all_certificates should be used instead."
271
+ ) ]
263
272
#[ corresponds( X509_STORE_get0_objects ) ]
264
273
pub fn objects ( & self ) -> & StackRef < X509Object > {
265
274
unsafe { StackRef :: from_ptr ( X509_STORE_get0_objects ( self . as_ptr ( ) ) ) }
266
275
}
276
+
277
+ /// Returns a stack of all the certificates in this store.
278
+ #[ corresponds( X509_STORE_get1_all_certs ) ]
279
+ #[ cfg( ossl300) ]
280
+ pub fn all_certificates ( & self ) -> Stack < X509 > {
281
+ unsafe { Stack :: from_ptr ( ffi:: X509_STORE_get1_all_certs ( self . as_ptr ( ) ) ) }
282
+ }
267
283
}
268
284
269
285
cfg_if ! {
Original file line number Diff line number Diff line change @@ -1177,3 +1177,18 @@ fn test_dist_point_null() {
1177
1177
let cert = X509 :: from_pem ( cert) . unwrap ( ) ;
1178
1178
assert ! ( cert. crl_distribution_points( ) . is_none( ) ) ;
1179
1179
}
1180
+
1181
+ #[ test]
1182
+ #[ cfg( ossl300) ]
1183
+ fn test_store_all_certificates ( ) {
1184
+ let cert = include_bytes ! ( "../../test/cert.pem" ) ;
1185
+ let cert = X509 :: from_pem ( cert) . unwrap ( ) ;
1186
+
1187
+ let store = {
1188
+ let mut b = X509StoreBuilder :: new ( ) . unwrap ( ) ;
1189
+ b. add_cert ( cert) . unwrap ( ) ;
1190
+ b. build ( )
1191
+ } ;
1192
+
1193
+ assert_eq ! ( store. all_certificates( ) . len( ) , 1 ) ;
1194
+ }
You can’t perform that action at this time.
0 commit comments