selfsigned
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@types/node-forge | 1.3.11 | 12.52 kB | MIT | prod | |
node-forge | 1.3.1 | 427.61 kB | (BSD-3-Clause OR GPL-2.0) | prod |
Selfsigned is a Node.js package that generates self-signed certificates along with private and public keys, including self-signed x509 certificates. This tool is paramount for testing and development purposes when SSL certificates are required but a CA signed certificate is not necessary.
To use selfsigned, first install the package using npm as follows:
npm install selfsigned
After installing, require the package in your JavaScript file. You can then use the generate
function in the selfsigned package to create the certificates. Here's a simple usage example in JavaScript:
var selfsigned = require('selfsigned');
var attrs = [{ name: 'commonName', value: 'contoso.com' }];
var pems = selfsigned.generate(attrs, { days: 365 });
console.log(pems)
This will log the private and public keys, along with the certificate. You can also generate the certificates asynchronously as follows:
selfsigned.generate(attrs, { days: 365 }, function (err, pems) {
console.log(pems)
});
Moreover, you have the option to generate client certificates by setting the clientCertificate
option to true
:
var pems = selfsigned.generate(null, { clientCertificate: true });
console.log(pems)
If you wish to override the default client CN, you can add another option for clientCertificateCN
:
var pems = selfsigned.generate(null, { clientCertificate: true, clientCertificateCN: 'FooBar' });
For detailed documentation on the selfsigned package and all feature options and capabilities, this link directs to the GitHub repository for the selfsigned npm package. Additionally, for information on configuring certificate attributes, refer to this link provided in the selfsigned readme. As with most npm packages, the readme file on the repository page acts as the core documentation and usage guide.