npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@expo/node-keytool

v0.0.4

Published

wrapper for keytool binary

Downloads

7

Readme

node-keytool

Basic wrapper for the Java keytool.

Usage

To include node-keytool in Node, first install it using npm:

npm install node-keytool

Second, require the library:

var Keytool = require('node-keytool');

Then, open / create your keystore file:

// Keytool(filename, storepass, options)
var store = Keytool('example.keystore', 'changeit', {debug: false, storetype: 'JCEKS'});

Finally, execute the desired functions on the Keytool object.

Constructor

Keytool(filename, storepass, options)

Constructs a Keytool object from a keystore file (filename) using the password from storepass.

Possible options

debug (boolean, if true all keytool output is piped to stdout/stderr)

storetype: keystore type (defaults to JKS, some actions require other storage types), executable (see below)

The library assumes that the keytool executable is on your PATH. In other cases, you can specify a path to the executable by passing the appropriate option:

var store = Keytool(filename, storepass, {executable: '/usr/bin/keytool'});

Functions

Most keytool actions are supported with their stdin input method or file-based operations. All operations expect a callback (cb) of the form function(err, result) as the last argument. See the manpage for keytool for more details.

Certificate Request: certreq

certreq(alias, keypass, dname, outfile, sigalg, cb)

Generates a certificate request for the given alias. If outfile is omitted or null, res.outdata will contain the certificate data.

Rename an alias: changealias

changealias(alias, keypass, destalias, cb)

Renames alias to destalias.

Export a certificate: exportcert

exportcert(alias, filename, rfcoutput, cb)

Exports the given certificate to the output file filename.

If rfcoutput is true the result is output in RFC 1421 compliant base64 encoding. Binary DER is the default.

Generate a keypair: genkeypair

genkeypair(alias, keypass, dname, validity, keysize, keyalg, sigalg, destalias, startdate, x509ext, cb)

Generates a keypair.

dname: Distinguished name, e.g. CN=abc,OU=dev

validity: Integer, Number of days this certificate should be valid

x509ext: String-Array, multiple extensions can be specified

startdate: JavaScript Date object

Generate a certificate: gencert

gencert(alias, keypass, dname, infile, datain, outfile, rfcoutput, validity, sigalg, startdate, cb)

Generates a certificate from the request given as a) an input file (parameter infile) or b) as a string in-memory (parameter datain).

If the parameter outfile is omitted or null, the result object contains the certificate data.

If the parameter dname is specified, this will be used in favor of the distinguished name used to generate the request.

startdate: JavaScript Date object

Import a certificate: importcert

importcert(alias, keypass, infile, datain, trustcacerts, cb)

Imports a certificate from a file (parameter infile) or from a string (parameter datain).

trustcacerts: Boolean

Import a passphrase: importpass

importpass(alias, keypass, data, keyalg, keysize, cb)

Imports a passphrase into the keystore.

Note: This operation is not supported by the default keystore type (JKS). Use JCEKS or similar if you need this.

Change a keys password: keypasswd

keypasswd(alias, keypass, newkeypass, cb)

Changes the password for the given alias from keypass to newkeypass.

Change the keystore password: storepasswd

storepasswd(newstorepass, cb)

Changes the password for the keystore itself.

Get basic information on a certificate in the keystore: getcert

getcert(file, data, sslserver, jarfile, rfcoutput, cb)

If rfcoutput is true, the callback will contain the BASE64 encoded representation of the certificate given in file (string, filename) or data (string).

If rfcoutput is false, basic certificate information will be parsed from the keytool output (signature algorithms, validity information, issuer / owner - where applicable).

Delete an alias from the keystore: deletealias

deletealias(alias, keypass, cb)

Removes an alias completely.

List the content of the keystore: getlist

getlist(cb)

Reads the content of the keystore. See examples/listcontent.js for an example on how to use the results.

Create empty keystore: create

create(cb)

Creates an empty keystore at the previously specified location. Fails if the targeted file already exists.