pub struct CertIdentity { /* private fields */ }Expand description
Extracted identity information from a certificate.
This struct holds the relevant identity information extracted from an X.509 certificate for ANS verification purposes.
In production, construct via CertIdentity::from_der. The CertIdentity::new
and CertIdentity::from_fingerprint_and_cn constructors are also public
for programmatic use and testing.
Implementations§
Source§impl CertIdentity
impl CertIdentity
Sourcepub fn common_name(&self) -> Option<&str>
pub fn common_name(&self) -> Option<&str>
Returns the Common Name (CN) from the certificate subject.
Sourcepub fn fingerprint(&self) -> &CertFingerprint
pub fn fingerprint(&self) -> &CertFingerprint
Returns the certificate fingerprint.
Sourcepub fn new(
common_name: Option<String>,
dns_sans: Vec<String>,
uri_sans: Vec<String>,
fingerprint: CertFingerprint,
) -> Self
pub fn new( common_name: Option<String>, dns_sans: Vec<String>, uri_sans: Vec<String>, fingerprint: CertFingerprint, ) -> Self
Create a new CertIdentity from components.
Use this when you’ve already extracted the certificate information
using your TLS library (e.g., rustls, native-tls, openssl).
If you have DER-encoded bytes, prefer CertIdentity::from_der.
Sourcepub fn from_der(der: &[u8]) -> Result<Self, CryptoError>
pub fn from_der(der: &[u8]) -> Result<Self, CryptoError>
Create from DER-encoded certificate bytes.
Computes the SHA-256 fingerprint and extracts the Subject CN and Subject Alternative Names (DNS, URI) using x509-parser.
Sourcepub fn from_fingerprint_and_cn(fingerprint: CertFingerprint, cn: String) -> Self
pub fn from_fingerprint_and_cn(fingerprint: CertFingerprint, cn: String) -> Self
Create from fingerprint and CN only.
Sets dns_sans to [cn] and uri_sans to empty.
If you have DER-encoded bytes, prefer CertIdentity::from_der.
Trait Implementations§
Source§impl Clone for CertIdentity
impl Clone for CertIdentity
Source§fn clone(&self) -> CertIdentity
fn clone(&self) -> CertIdentity
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more