pub struct Certificate(/* private fields */);Expand description
Represents an X.509 certificate.
Implementations§
Source§impl Certificate
impl Certificate
Sourcepub fn from_der(der: Vec<u8>) -> Result<Self, InvalidCertificate>
pub fn from_der(der: Vec<u8>) -> Result<Self, InvalidCertificate>
Constructs a new Certificate from DER-encoded binary data.
Sourcepub async fn load_pemfile(
filepath: impl AsRef<Path>,
) -> Result<Self, PemLoadError>
pub async fn load_pemfile( filepath: impl AsRef<Path>, ) -> Result<Self, PemLoadError>
Loads the first certificate found in a PEM-encoded file.
Filters out any PEM sections that are not certificate.
Returns a PemLoadError::NoCertificateSection if no certificate is found in the file.
Sourcepub async fn store_pemfile(&self, filepath: impl AsRef<Path>) -> Result<()>
pub async fn store_pemfile(&self, filepath: impl AsRef<Path>) -> Result<()>
Stores the certificate in PEM format into a file asynchronously.
If the file does not exist, it will be created. If the file exists, its contents will be truncated before writing.
Sourcepub fn der(&self) -> &[u8] ⓘ
pub fn der(&self) -> &[u8] ⓘ
Returns a reference to the DER-encoded binary data of the certificate.
Sourcepub fn to_pem(&self) -> String
pub fn to_pem(&self) -> String
Converts the X.509 certificate to the PEM (Privacy-Enhanced Mail) format.
§Returns
A String containing the PEM-encoded representation of the certificate.
Sourcepub fn hash(&self) -> Sha256Digest
pub fn hash(&self) -> Sha256Digest
Computes certificate’s hash.
The hash is the SHA-256 of the DER encoding of the certificate.
This function can be used to make a web client accept a self-signed
certificate by using the WebTransportOptions.serverCertificateHashes W3C API.
Trait Implementations§
Source§impl Clone for Certificate
impl Clone for Certificate
Source§fn clone(&self) -> Certificate
fn clone(&self) -> Certificate
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more