macos-export-certificate-and-key
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -1,6 +0,22 @@ | ||
declare function exportCertificateAndPrivateKey(input: { | ||
declare type LookupOptions = { | ||
subject: string; | ||
thumbprint?: never; | ||
} | { | ||
subject?: never; | ||
thumbprint: Uint8Array; | ||
}): { passphrase: string; pfx: Uint8Array; }; | ||
export = exportCertificateAndPrivateKey; | ||
}; | ||
declare interface PfxResult { | ||
passphrase: string; | ||
pfx: Uint8Array; | ||
}; | ||
declare function exportCertificateAndPrivateKey(input: LookupOptions): PfxResult; | ||
declare namespace exportCertificateAndPrivateKey { | ||
function exportCertificateAndPrivateKey(input: LookupOptions): PfxResult; | ||
function exportSystemCertificates(input: StoreOptions): string[]; | ||
} | ||
export = exportCertificateAndPrivateKey; |
10
index.js
@@ -1,6 +0,6 @@ | ||
const { exportCertificate } = require('bindings')('macos_export_certificate_and_key'); | ||
const { exportCertificateAndKey, exportAllCertificates } = require('bindings')('macos_export_certificate_and_key'); | ||
const { randomBytes } = require('crypto'); | ||
const util = require('util'); | ||
module.exports = function exportCertificateAndPrivateKey({ | ||
function exportCertificateAndPrivateKey({ | ||
subject, | ||
@@ -23,3 +23,3 @@ thumbprint | ||
const passphrase = randomBytes(12).toString('hex'); | ||
const pfx = exportCertificate( | ||
const pfx = exportCertificateAndKey( | ||
subject ? { subject } : { thumbprint }, | ||
@@ -30,1 +30,5 @@ passphrase | ||
}; | ||
module.exports = exportCertificateAndPrivateKey; | ||
module.exports.exportCertificateAndPrivateKey = exportCertificateAndPrivateKey; | ||
module.exports.exportSystemCertificates = exportAllCertificates; |
@@ -13,3 +13,3 @@ { | ||
"name": "macos-export-certificate-and-key", | ||
"version": "1.0.3", | ||
"version": "1.1.0", | ||
"description": "Export a certificate and its corresponding private key from the MacOS default keychain", | ||
@@ -16,0 +16,0 @@ "repository": { |
# macos-export-certificate-and-key | ||
Export a certificate and its corresponding private key from the macOS default keychain. This module is a native addon. It will only successfully work on macOS 10.12+. No prebuilt binaries are currently provided. | ||
This module returns a single certificate and its private key combination as a `.pfx` file, along with a random passphrase that has been used for encrypting the file. It will throw an exception if no relevant certificate could be found. The certificate in question can be specified either through its subject line string or its thumbprint. | ||
Access the macOS system certificate and key store. | ||
This module is a native addon. It will only successfully work on macOS 10.12+. No prebuilt binaries are currently provided. | ||
## API | ||
### `exportCertificateAndPrivateKey(opts?)` | ||
Export a certificate and its corresponding private key from the macOS CA store. | ||
Valid options are: | ||
- `subject`: Subject line of the certificate/key as a string. | ||
- `thumbprint`: Thumbprint of the certificate/key as a Uint8Array. | ||
Either `subject` or `thumbprint` must be provided. | ||
This function returns a single certificate (and by default its private key) | ||
combination as a .pfx file, along with a random passphrase that has been | ||
used for encrypting the file. | ||
It will throw an exception if no relevant certificate could be found. | ||
The certificate in question can be specified either through its subject line | ||
string or its thumbprint. | ||
When exporting, the user will be prompted to enter his password to allow keychain access. | ||
### `exportSystemCertificates()` | ||
Export all system certificates (no private keys). | ||
## Testing | ||
You need to import [`testkeys\certificate.pfx`](./testkeys/certificate.pfx) manually into your local keychain in order for the tests to pass. The password for the file is `pass`. |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13559
45
33