Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added function to set exportable private key flag #96

Merged
merged 2 commits into from
Dec 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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