https://github.com/aleclarson/cert-utils
https://github.com/aleclarson/cert-utils
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/aleclarson/cert-utils
- Owner: aleclarson
- License: mit
- Created: 2017-09-21T17:58:09.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2018-12-05T16:53:58.000Z (over 7 years ago)
- Last Synced: 2025-12-25T14:55:43.008Z (6 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cert-utils v1.2.0 
> npm install aleclarson/cert-utils#1.2.0
```js
const certUtils = require('cert-utils');
```
### certUtils.der(cert)
Convert a certificate to DER format.
```js
certUtils.der(
fs.readFileSync('cert.pem')
).then(cert => {
console.log(cert); // <= `cert` is a Buffer object
});
```
### certUtils.req(options)
Generate a CSR in either PEM or DER format.
**Options:**
- `key: string|buffer` The private key in PEM format
- `format: string?` The output format (defaults to `PEM`)
- `domain: string?` The validated domain, overrides `domains`
- `domains: string|array?` The validated domain(s)
- `subject: object?` The details embedded in the CSR, all keys are optional strings
- `email`
- `country`
- `state`
- `city`
- `company`
- `division`
```js
certUtils.req({
key: fs.readFileSync('key.pem'),
domain: 'example.com',
subject: {
email: 'you@example.com',
country: 'US',
state: 'CA',
city: 'Palo Alto',
company: 'Google',
}
}).then(csr => {
console.log(csr); // <= `csr` is a Buffer object
});
```