Skip to content

Commit ea075d1

Browse files
authored
Merge pull request #2115 from davidben/x509-purpose-get-id
Use X509_PURPOSE_get_id instead of struct access
2 parents efe619c + 9cafc73 commit ea075d1

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

openssl-sys/src/handwritten/x509.rs

+1
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ pub struct X509_PURPOSE {
702702
const_ptr_api! {
703703
extern "C" {
704704
pub fn X509_PURPOSE_get_by_sname(sname: #[const_ptr_if(any(ossl110, libressl280))] c_char) -> c_int;
705+
pub fn X509_PURPOSE_get_id(purpose: #[const_ptr_if(any(ossl110, libressl280))] X509_PURPOSE) -> c_int;
705706
}
706707
}
707708
extern "C" {

openssl/src/x509/mod.rs

+9-3
Original file line numberDiff line numberDiff line change
@@ -2538,7 +2538,7 @@ impl X509PurposeRef {
25382538
unsafe {
25392539
let sname = CString::new(sname).unwrap();
25402540
cfg_if! {
2541-
if #[cfg(any(ossl110, libressl280))] {
2541+
if #[cfg(any(ossl110, libressl280, boringssl))] {
25422542
let purpose = cvt_n(ffi::X509_PURPOSE_get_by_sname(sname.as_ptr() as *const _))?;
25432543
} else {
25442544
let purpose = cvt_n(ffi::X509_PURPOSE_get_by_sname(sname.as_ptr() as *mut _))?;
@@ -2569,8 +2569,14 @@ impl X509PurposeRef {
25692569
/// - `X509_PURPOSE_TIMESTAMP_SIGN`
25702570
pub fn purpose(&self) -> X509PurposeId {
25712571
unsafe {
2572-
let x509_purpose: *mut ffi::X509_PURPOSE = self.as_ptr();
2573-
X509PurposeId::from_raw((*x509_purpose).purpose)
2572+
cfg_if! {
2573+
if #[cfg(any(ossl110, libressl280, boringssl))] {
2574+
let x509_purpose = self.as_ptr() as *const ffi::X509_PURPOSE;
2575+
} else {
2576+
let x509_purpose = self.as_ptr() as *mut ffi::X509_PURPOSE;
2577+
}
2578+
}
2579+
X509PurposeId::from_raw(ffi::X509_PURPOSE_get_id(x509_purpose))
25742580
}
25752581
}
25762582
}

0 commit comments

Comments
 (0)