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 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for CertIdentity
impl RefUnwindSafe for CertIdentity
impl Send for CertIdentity
impl Sync for CertIdentity
impl Unpin for CertIdentity
impl UnsafeUnpin for CertIdentity
impl UnwindSafe for CertIdentity
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more