Struct pkcs8::PrivateKeyDocument
source · [−]pub struct PrivateKeyDocument(_);
Expand description
PKCS#8 private key document.
This type provides storage for PrivateKeyInfo
encoded as ASN.1 DER
with the invariant that the contained-document is “well-formed”, i.e. it
will parse successfully according to this crate’s parsing rules.
Implementations
sourceimpl PrivateKeyDocument
impl PrivateKeyDocument
sourcepub fn private_key_info(&self) -> PrivateKeyInfo<'_>
pub fn private_key_info(&self) -> PrivateKeyInfo<'_>
Parse the PrivateKeyInfo
contained in this PrivateKeyDocument
sourcepub fn from_der(bytes: &[u8]) -> Result<Self>
pub fn from_der(bytes: &[u8]) -> Result<Self>
Parse PrivateKeyDocument
from ASN.1 DER-encoded PKCS#8
sourcepub fn from_pem(s: &str) -> Result<Self>
pub fn from_pem(s: &str) -> Result<Self>
Parse PrivateKeyDocument
from PEM-encoded PKCS#8.
PEM-encoded private keys can be identified by the leading delimiter:
-----BEGIN PRIVATE KEY-----
sourcepub fn to_pem(&self) -> Zeroizing<String>
pub fn to_pem(&self) -> Zeroizing<String>
Serialize PrivateKeyDocument
as self-zeroizing PEM-encoded PKCS#8 string.
sourcepub fn to_pem_with_le(&self, line_ending: LineEnding) -> Zeroizing<String>
pub fn to_pem_with_le(&self, line_ending: LineEnding) -> Zeroizing<String>
Serialize PrivateKeyDocument
as self-zeroizing PEM-encoded PKCS#8 string
with the given LineEnding
.
sourcepub fn read_der_file(path: impl AsRef<Path>) -> Result<Self>
pub fn read_der_file(path: impl AsRef<Path>) -> Result<Self>
Load PrivateKeyDocument
from an ASN.1 DER-encoded file on the local
filesystem (binary format).
sourcepub fn read_pem_file(path: impl AsRef<Path>) -> Result<Self>
pub fn read_pem_file(path: impl AsRef<Path>) -> Result<Self>
Load PrivateKeyDocument
from a PEM-encoded file on the local filesystem.
Trait Implementations
sourceimpl Clone for PrivateKeyDocument
impl Clone for PrivateKeyDocument
sourcefn clone(&self) -> PrivateKeyDocument
fn clone(&self) -> PrivateKeyDocument
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for PrivateKeyDocument
impl Debug for PrivateKeyDocument
sourceimpl From<&'_ PrivateKeyInfo<'_>> for PrivateKeyDocument
impl From<&'_ PrivateKeyInfo<'_>> for PrivateKeyDocument
sourcefn from(private_key_info: &PrivateKeyInfo<'_>) -> PrivateKeyDocument
fn from(private_key_info: &PrivateKeyInfo<'_>) -> PrivateKeyDocument
Converts to this type from the input type.
sourceimpl From<PrivateKeyInfo<'_>> for PrivateKeyDocument
impl From<PrivateKeyInfo<'_>> for PrivateKeyDocument
sourcefn from(private_key_info: PrivateKeyInfo<'_>) -> PrivateKeyDocument
fn from(private_key_info: PrivateKeyInfo<'_>) -> PrivateKeyDocument
Converts to this type from the input type.
sourceimpl FromStr for PrivateKeyDocument
impl FromStr for PrivateKeyDocument
Auto Trait Implementations
impl RefUnwindSafe for PrivateKeyDocument
impl Send for PrivateKeyDocument
impl Sync for PrivateKeyDocument
impl Unpin for PrivateKeyDocument
impl UnwindSafe for PrivateKeyDocument
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more