From 93fe14a77860edb8b204ed6a8f0eb8a19cb0caf0 Mon Sep 17 00:00:00 2001 From: Cristian <7946103+cristianbdg@users.noreply.github.com> Date: Wed, 30 Aug 2023 23:40:41 +0200 Subject: [PATCH 1/2] Added function to set exportable private key flag --- src/cert_store.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cert_store.rs b/src/cert_store.rs index 484eaab..09e725a 100644 --- a/src/cert_store.rs +++ b/src/cert_store.rs @@ -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; From 6d08a7afda8b988fbbebc60b22083b3c3a0914b1 Mon Sep 17 00:00:00 2001 From: Cristian Boya <7946103+cristianbdg@users.noreply.github.com> Date: Tue, 5 Sep 2023 10:18:08 +0200 Subject: [PATCH 2/2] [EXPORTABLE_PRIVATE_KEY_FLAG] Added function to set machine keyset flag --- src/cert_store.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/cert_store.rs b/src/cert_store.rs index 09e725a..2ba37d0 100644 --- a/src/cert_store.rs +++ b/src/cert_store.rs @@ -314,7 +314,7 @@ impl PfxImportOptions { ) } - /// If set, the private key in the archive will be exportable. + /// If set, the private key in the archive will be exportable. pub fn exportable_private_key( &mut self, exportable_private_key: bool, @@ -331,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 { unsafe {