New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

cert2json

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cert2json

Convert x509 certificate to json

latest
Source
npmnpm
Version
1.0.13
Version published
Weekly downloads
379
5.57%
Maintainers
1
Weekly downloads
 
Created
Source

cert2json

Convert a x509 certificate to JSON format
View Demo · Report Bug · Request Feature

Table of Contents

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.

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

License

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

Keywords

x509

FAQs

Package last updated on 10 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts