Skip to content

Commit 815a210

Browse files
committed
X509CrlRef::get_by_cert(): support passing of cert by non-owned reference
Support the passing of the X509 certificate by a non-owned reference. In addition, add a test for it. Signed-off-by: Marc Hartmayer <[email protected]>
1 parent 450110f commit 815a210

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

openssl/src/x509/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1910,7 +1910,7 @@ impl X509CrlRef {
19101910

19111911
/// Get the revocation status of a certificate
19121912
#[corresponds(X509_CRL_get0_by_cert)]
1913-
pub fn get_by_cert<'a>(&'a self, cert: &X509) -> CrlStatus<'a> {
1913+
pub fn get_by_cert<'a>(&'a self, cert: &X509Ref) -> CrlStatus<'a> {
19141914
unsafe {
19151915
let mut ret = ptr::null_mut::<ffi::X509_REVOKED>();
19161916
let status =

openssl/src/x509/tests.rs

+11
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,17 @@ fn test_load_crl() {
694694
cert.serial_number().to_bn().unwrap(),
695695
"revoked and cert serial numbers should match"
696696
);
697+
698+
let revoked = match crl.get_by_cert(cert.as_ref()) {
699+
CrlStatus::Revoked(revoked) => revoked,
700+
_ => panic!("cert should be revoked"),
701+
};
702+
703+
assert_eq!(
704+
revoked.serial_number().to_bn().unwrap(),
705+
cert.serial_number().to_bn().unwrap(),
706+
"revoked and cert serial numbers should match"
707+
);
697708
}
698709

699710
#[test]

0 commit comments

Comments
 (0)