1.0.13 • Published 10 months ago

cert2json v1.0.13

Weekly downloads
25
License
MIT
Repository
github
Last release
10 months ago

About The Project

This project converts x509 certificates into JSON format. It provides both a command line interface and an API.

Getting Started

To get a local copy up and running follow these simple steps.

Install CLI

Run the following command to install the CLI

npm install -g cert2json

Install API

In your npm package install the dependency

npm install cert2json

Usage

CLI Example

The CLI will print the JSON. You can use jq to process the output. Below is an example printing the certificate issuer.

➜  cert2json -h
usage: cert2json file
➜  cert2json google.com.cer | jq '.tbs.issuer.full'
"C=US, O=Google Trust Services, CN=GTS CA 1O1"
➜  

API Examples

Import cert2json and call parseFromFile. The certificate can be DER or PEM format.

// Import the library
const cert2json = require('cert2json')

// Parse the certificate, resulting in a JSON object
const cert = cert2json.parseFromFile('./certificates/google.com.cer')

// Print the issuer
console.log(cert.tbs.issuer.full)

Results in:

C=US, O=Google Trust Services, CN=GTS CA 1O1

Alternatively you can parse the certificate from memory. The parse function expects a Buffer containing the certificate data.

// Import the library
const cert2json = require('cert2json')
const fs = require('fs')

// Read the certificate into a buffer
const certificatePath = './certificates/example.com.cer'
const certificateBuffer = fs.readFileSync(certificatePath)

// Parse the buffer contents
const cert = cert2json.parse(certificateBuffer)

// Print the certificate
console.log(JSON.stringify(cert, null, 2))

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

1.0.13

10 months ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.10

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago