Package Exports
- add-trusted-cert
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (add-trusted-cert) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
add-trusted-cert
An API for calling the security add-trusted-cert command in macOS to add certificates to the system keychain.
For more information, see man security and search for the add-trusted-cert command.
Usage
import { addTrustedCert, POLICY_CONSTRAINTS, RESULT_TYPES } from 'add-trusted-cert'
(async () => {
// Add a cert trusted for SSL
await addTrustedCert({
resultType: RESULT_TYPES.TRUST_ROOT,
policyConstraint: POLICY_CONSTRAINTS.SSL,
// You might need this
sudo: true
}, 'server.pem.crt')
})()API
addTrustedCert(options, certFile) ⇒ Promise.<string>
Add certificate (in DER or PEM format) from certFile to per-user or local Admin Trust Settings. When modifying per-user Trust Settings, user authentication is required via an authentication dialog. When modifying admin Trust Settings, the process must be running as root, or admin authentication is required.
Returns: Promise.<string> - Output of the security add-trusted-cert command
See: man security add-trusted-cert
| Param | Type | Description |
|---|---|---|
| options | object |
|
| [options.addToAdminCertStore] | boolean |
If true, adds the cert to the admin cert store |
| [options.resultType] | string |
|
| [options.policyConstraint] | Array.<string> | string |
Policy constraints |
| [options.appPath] | string |
Application constraint |
| [options.policyString] | string |
Policy-specific string |
| [options.allowedError] | Array.<(string|number)> | number | string |
|
| [options.keyUsageCode] | number |
Key usage. For more than one usage, add values together (except -1). |
| [options.keychain] | string |
Keychain to which the cert is added. Default is '/Library/Keychains/System.keychain'. |
| [options.settingsFileIn] | string |
Input trust settings file; default is user domain |
| [options.settingsFileOut] | string |
Output trust settings file; default is user domain |
| [options.sudo] | boolean |
If true, use sudo to execute the command. |
| certFile | string |
Certificate file to add |
| [execaOpts] | object |
Options to supply to the execa call |