Struct wtransport::tls::PrivateKey
source · pub struct PrivateKey(/* private fields */);
Expand description
Represents a private key.
Implementations§
source§impl PrivateKey
impl PrivateKey
sourcepub fn from_der_pkcs8(der: Vec<u8>) -> Self
pub fn from_der_pkcs8(der: Vec<u8>) -> Self
Constructs a new PrivateKey
from DER-encoded PKCS#8 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 private key found in a PEM-encoded file.
Filters out any PEM sections that are not private key.
Returns a PemLoadError::NoPrivateKeySection
if no private key is found in the file.
sourcepub async fn store_secret_pemfile(
&self,
filepath: impl AsRef<Path>
) -> Result<()>
pub async fn store_secret_pemfile( &self, filepath: impl AsRef<Path> ) -> Result<()>
Stores the private key 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 secret_der(&self) -> &[u8] ⓘ
pub fn secret_der(&self) -> &[u8] ⓘ
Returns a reference to the DER-encoded binary data of the private key.
sourcepub fn to_secret_pem(&self) -> String
pub fn to_secret_pem(&self) -> String
Converts the private key to PEM format.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PrivateKey
impl RefUnwindSafe for PrivateKey
impl Send for PrivateKey
impl Sync for PrivateKey
impl Unpin for PrivateKey
impl UnwindSafe for PrivateKey
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
Mutably borrows from an owned value. Read more