cert-info.js/README.md

68 lines
1.3 KiB
Markdown
Raw Normal View History

2018-12-16 21:51:24 -07:00
# [certpem.js](https://git.coolaj86.com/coolaj86/cert-info.js)
2016-08-11 09:43:11 -06:00
2016-08-11 09:15:10 -06:00
Read basic info from a cert.pem / x509 certificate.
2016-08-11 09:43:11 -06:00
2018-08-16 19:47:37 -06:00
Used for [Greenlock.js](https://git.coolaj86.com/coolaj86/greenlock-express.js)
2018-12-16 21:51:24 -07:00
# Install
2016-08-11 09:43:11 -06:00
```bash
# bin
npm install --global certpem
# node.js library
npm install --save certpem
```
2018-12-16 21:51:24 -07:00
# Usage
2016-08-11 09:43:11 -06:00
2018-12-16 21:51:24 -07:00
## CLI
2016-08-11 10:06:11 -06:00
2016-08-11 09:43:11 -06:00
For basic info (subject, altnames, issuedAt, expiresAt):
```bash
certpem /path/to/cert.pem
```
Output all info by passing `--debug` or use `--json` to see the basic info pretty-printed.
2018-12-16 21:51:24 -07:00
## node.js
2016-08-11 10:06:11 -06:00
2016-08-11 09:43:11 -06:00
```javascript
'use strict';
var certpem = require('certpem').certpem
var cert = fs.readFile('cert.pem', 'ascii', function (err, certstr) {
2016-08-11 10:01:24 -06:00
// basic info
2016-08-11 10:06:55 -06:00
console.info(certpem.info(certstr));
2016-08-11 10:01:24 -06:00
// way too much info
2018-08-16 19:47:37 -06:00
// (requires npm install --save node.extend@1)
2016-08-11 10:06:55 -06:00
console.info(certpem.debug(certstr));
2016-08-11 10:01:24 -06:00
2016-08-11 09:43:11 -06:00
});
```
2016-08-11 10:06:55 -06:00
Example output:
2016-08-11 09:43:11 -06:00
```javascript
{
2018-12-16 21:51:24 -07:00
"subject": "localhost.example.com",
2016-08-11 09:43:11 -06:00
"altnames": [
2018-12-16 21:51:24 -07:00
"localhost.example.com"
2016-08-11 09:43:11 -06:00
],
"issuedAt": 1465516800000,
"expiresAt": 1499731199000
}
```
2016-08-11 10:06:11 -06:00
With a few small changes this could also work in the browser (that's how its dependencies are designed).
2018-12-16 21:51:24 -07:00
# Legal
[certpem.js](https://git.coolaj86.com/coolaj86/certpem.js) |
MPL-2.0 |
[Terms of Use](https://therootcompany.com/legal/#terms) |
[Privacy Policy](https://therootcompany.com/legal/#privacy)