Struct x509_signature::X509Certificate
source · [−]pub struct X509Certificate<'a> { /* private fields */ }
Expand description
A parsed (but not validated) X.509 version 3 certificate.
Implementations
sourceimpl<'a> X509Certificate<'a>
impl<'a> X509Certificate<'a>
sourcepub fn das(&self) -> DataAlgorithmSignature<'a>
pub fn das(&self) -> DataAlgorithmSignature<'a>
The tbsCertificate, signatureAlgorithm, and signature
sourcepub fn serial(&self) -> &'a [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn serial(&self) -> &'a [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
The serial number. Big-endian and non-empty. The first byte is guaranteed to be non-zero.
sourcepub fn issuer(&self) -> &'a [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn issuer(&self) -> &'a [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
The X.509 issuer. This has not been validated and is not trusted. In particular, it is not guaranteed to be valid ASN.1 DER.
sourcepub fn not_before(&self) -> ASN1Time
pub fn not_before(&self) -> ASN1Time
The earliest time, in seconds since the Unix epoch, that the certificate is valid.
Will always be between MIN_ASN1_TIMESTAMP
and
MAX_ASN1_TIMESTAMP
, inclusive.
sourcepub fn not_after(&self) -> ASN1Time
pub fn not_after(&self) -> ASN1Time
The latest time, in seconds since the Unix epoch, that the certificate is valid.
Will always be between MIN_ASN1_TIMESTAMP
and
MAX_ASN1_TIMESTAMP
, inclusive.
sourcepub fn subject(&self) -> &'a [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn subject(&self) -> &'a [u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
X.509 subject. This has not been validated and is not trusted. In particular, it is not guaranteed to be valid ASN.1 DER.
sourcepub fn subject_public_key_info(&self) -> SubjectPublicKeyInfo<'a>
pub fn subject_public_key_info(&self) -> SubjectPublicKeyInfo<'a>
The subjectPublicKeyInfo, encoded as ASN.1 DER. There is no guarantee that the OID or public key are valid ASN.1 DER, but if they are not, all methods that check signatures will fail.
sourcepub fn extensions(&self) -> ExtensionIterator<'a>
pub fn extensions(&self) -> ExtensionIterator<'a>
An iterator over the certificate’s extensions.
sourcepub fn check_signature(
&self,
algorithm: SignatureScheme,
message: &[u8],
signature: &[u8]
) -> Result<(), Error>
pub fn check_signature(
&self,
algorithm: SignatureScheme,
message: &[u8],
signature: &[u8]
) -> Result<(), Error>
Verify a signature made by the certificate.
sourcepub fn check_tls13_signature(
&self,
algorithm: SignatureScheme,
message: &[u8],
signature: &[u8]
) -> Result<(), Error>
pub fn check_tls13_signature(
&self,
algorithm: SignatureScheme,
message: &[u8],
signature: &[u8]
) -> Result<(), Error>
Verify a signature made by the certificate, applying the restrictions of TLSv1.3:
- ECDSA algorithms where the hash has a different size than the curve are not allowed.
- RSA PKCS1.5 signatures are not allowed.
This is a good choice for new protocols and applications. Note that extensions are not checked, so applications must process extensions themselves.
sourcepub fn check_tls12_signature(
&self,
algorithm: SignatureScheme,
message: &[u8],
signature: &[u8]
) -> Result<(), Error>
pub fn check_tls12_signature(
&self,
algorithm: SignatureScheme,
message: &[u8],
signature: &[u8]
) -> Result<(), Error>
Verify a signature made by the certificate, applying the restrictions of TLSv1.2:
- RSA-PSS signatures are not allowed.
This should not be used outside of a TLSv1.2 implementation. Note that extensions are not checked, so applications must process extensions themselves.
sourcepub fn valid_at_timestamp(&self, now: i64) -> Result<(), Error>
pub fn valid_at_timestamp(&self, now: i64) -> Result<(), Error>
Check that the certificate is valid at time now
, in seconds since the
Epoch.
sourcepub fn tbs_certificate(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn tbs_certificate(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
The tbsCertficate
sourcepub fn signature_algorithm_id(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn signature_algorithm_id(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
The AlgorithmId
of the algorithm used to sign this certificate
sourcepub fn signature(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn signature(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
The signature of the certificate
sourcepub fn check_signature_from(
&self,
cert: &X509Certificate<'_>
) -> Result<(), Error>
pub fn check_signature_from(
&self,
cert: &X509Certificate<'_>
) -> Result<(), Error>
Verify that this certificate was signed by cert
’s secret key.
This does not check that cert
is a certificate authority.
sourcepub fn check_issued_by(&self, cert: &X509Certificate<'_>) -> Result<(), Error>
pub fn check_issued_by(&self, cert: &X509Certificate<'_>) -> Result<(), Error>
As above, but also check that self
’s issuer is cert
’s subject.
sourcepub fn check_self_signature(&self) -> Result<(), Error>
👎 Deprecated since 0.3.3: Use check_self_issued instead
pub fn check_self_signature(&self) -> Result<(), Error>
Use check_self_issued instead
Check that this certificate is self-signed. This does not check that the subject and issuer are equal.
sourcepub fn check_self_issued(&self) -> Result<(), Error>
pub fn check_self_issued(&self) -> Result<(), Error>
Check that this certificate is self-signed, and that the subject and issuer are equal.
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for X509Certificate<'a>
impl<'a> Send for X509Certificate<'a>
impl<'a> Sync for X509Certificate<'a>
impl<'a> Unpin for X509Certificate<'a>
impl<'a> UnwindSafe for X509Certificate<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more