Skip to content

Commit

Permalink
Keep semver compat
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed Nov 28, 2024
1 parent 63604d5 commit aa16061
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
16 changes: 2 additions & 14 deletions boring/src/ssl/test/custom_verify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,7 @@ fn untrusted_with_set_cert() {
let cert = ssl.peer_certificate().unwrap();
let cert_chain = ssl.peer_cert_chain().unwrap();

assert_eq!(
unsafe {
#[allow(deprecated)]
store.objects().len()
},
0
);
assert_eq!(store.objects_len(), 0);

X509StoreContext::new()
.unwrap()
Expand Down Expand Up @@ -100,13 +94,7 @@ fn trusted_with_set_cert() {
let cert = ssl.peer_certificate().unwrap();
let cert_chain = ssl.peer_cert_chain().unwrap();

assert_eq!(
unsafe {
#[allow(deprecated)]
store.objects().len()
},
1
);
assert_eq!(store.objects_len(), 1);

X509StoreContext::new()
.unwrap()
Expand Down
11 changes: 10 additions & 1 deletion boring/src/x509/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ foreign_type_and_impl_send_sync! {
}

impl X509StoreRef {
/// **Warning: this method is unsound**
///
/// Get a reference to the cache of certificates in this store.
///
/// # Safety
Expand All @@ -137,7 +139,14 @@ impl X509StoreRef {
note = "This method is unsound https://github.com/sfackler/rust-openssl/issues/2096"
)]
#[corresponds(X509_STORE_get0_objects)]
pub unsafe fn objects(&self) -> &StackRef<X509Object> {
pub fn objects(&self) -> &StackRef<X509Object> {
unsafe { StackRef::from_ptr(ffi::X509_STORE_get0_objects(self.as_ptr())) }
}

/// For testing only, where it doesn't have to expose an unsafe pointer
#[cfg(test)]
#[allow(deprecated)]
pub fn objects_len(&self) -> usize {
self.objects().len()
}
}

0 comments on commit aa16061

Please sign in to comment.