Skip to content

Commit

Permalink
Merge pull request #96 from cristianbdg/exportable_private_key_flag
Browse files Browse the repository at this point in the history
Added function to set exportable private key flag
  • Loading branch information
steffengy authored Dec 24, 2023
2 parents 2b6402a + 6d08a7a commit 9c7cb88
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/cert_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,14 @@ impl PfxImportOptions {
)
}

/// If set, the private key in the archive will be exportable.
pub fn exportable_private_key(
&mut self,
exportable_private_key: bool,
) -> &mut PfxImportOptions {
self.flag(Cryptography::CRYPT_EXPORTABLE, exportable_private_key)
}

fn flag(&mut self, flag: u32, set: bool) -> &mut PfxImportOptions {
if set {
self.flags |= flag;
Expand All @@ -323,6 +331,11 @@ impl PfxImportOptions {
self
}

/// If set, the private keys are stored under the local computer and not under the current user.
pub fn machine_keyset(&mut self, machine_keyset: bool) -> &mut PfxImportOptions {
self.flag(Cryptography::CRYPT_MACHINE_KEYSET, machine_keyset)
}

/// Imports certificates from a PKCS #12 archive, returning a `CertStore` containing them.
pub fn import(&self, data: &[u8]) -> io::Result<CertStore> {
unsafe {
Expand Down

0 comments on commit 9c7cb88

Please sign in to comment.