Skip to main content

security_framework/os/macos/
certificate_oids.rs

1//! OIDs associated with certificate properties.
2use core_foundation::base::TCFType;
3use core_foundation::string::CFString;
4use core_foundation_sys::string::CFStringRef;
5use security_framework_sys::certificate_oids::kSecOIDX509V1SignatureAlgorithm;
6
7/// An identifier of a property of a certificate.
8#[derive(Copy, Clone)]
9pub struct CertificateOid(CFStringRef);
10
11#[allow(missing_docs)]
12impl CertificateOid {
13    #[inline(always)]
14    #[must_use]
15    pub fn x509_v1_signature_algorithm() -> Self {
16        unsafe { Self(kSecOIDX509V1SignatureAlgorithm) }
17    }
18
19    /// Returns the underlying raw pointer corresponding to this OID.
20    #[inline(always)]
21    #[must_use]
22    // FIXME: Don't expose CFStringRef in Rust APIs
23    pub fn as_ptr(&self) -> CFStringRef {
24        self.0
25    }
26
27    /// Returns the string representation of the OID.
28    #[inline]
29    #[must_use]
30    // FIXME: Don't expose CFString in Rust APIs
31    pub fn to_str(&self) -> CFString {
32        unsafe { CFString::wrap_under_get_rule(self.0) }
33    }
34}