pub struct SigningIdentity { /* private fields */ }Expand description
A private key together with the certificate chain that identifies it.
Constructors check that the key matches the leaf certificate, so a
SigningIdentity can always produce verifiable signatures.
use apk::sign::SigningIdentity;
let identity = SigningIdentity::from_pem_file("release.pem")?;
println!("signing as {}", identity.certificate().subject());Implementations§
Source§impl SigningIdentity
impl SigningIdentity
Sourcepub fn new(key: PrivateKey, chain: Vec<Certificate>) -> Result<Self, KeyError>
pub fn new(key: PrivateKey, chain: Vec<Certificate>) -> Result<Self, KeyError>
Pairs key with chain (leaf first).
Sourcepub fn from_pem(pem: &str) -> Result<Self, KeyError>
pub fn from_pem(pem: &str) -> Result<Self, KeyError>
Parses a PEM bundle holding a private key (PRIVATE KEY,
RSA PRIVATE KEY, or EC PRIVATE KEY) and one or more CERTIFICATEs.
Sourcepub fn from_encrypted_pem(pem: &str, password: &str) -> Result<Self, KeyError>
pub fn from_encrypted_pem(pem: &str, password: &str) -> Result<Self, KeyError>
Like from_pem, also accepting an
ENCRYPTED PRIVATE KEY (PKCS#8, PBES2) unlocked with password.
Sourcepub fn from_pem_file(path: impl AsRef<Path>) -> Result<Self, Error>
pub fn from_pem_file(path: impl AsRef<Path>) -> Result<Self, Error>
Reads a PEM bundle from a file.
Sourcepub fn from_der(
private_key_pkcs8: &[u8],
certificate: &[u8],
) -> Result<Self, KeyError>
pub fn from_der( private_key_pkcs8: &[u8], certificate: &[u8], ) -> Result<Self, KeyError>
Parses a PKCS#8 private key and a certificate, both DER-encoded.
pub fn key(&self) -> &PrivateKey
Sourcepub fn certificate(&self) -> &Certificate
pub fn certificate(&self) -> &Certificate
The leaf certificate.
Sourcepub fn chain(&self) -> &[Certificate]
pub fn chain(&self) -> &[Certificate]
The certificate chain, leaf first.
Trait Implementations§
Source§impl Clone for SigningIdentity
impl Clone for SigningIdentity
Auto Trait Implementations§
impl Freeze for SigningIdentity
impl RefUnwindSafe for SigningIdentity
impl Send for SigningIdentity
impl Sync for SigningIdentity
impl Unpin for SigningIdentity
impl UnsafeUnpin for SigningIdentity
impl UnwindSafe for SigningIdentity
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