Gathering detailed insights and metrics for pem
Gathering detailed insights and metrics for pem
Gathering detailed insights and metrics for pem
Gathering detailed insights and metrics for pem
Create private keys and certificates with node.js
npm install pem
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
570 Stars
456 Commits
129 Forks
15 Watching
17 Branches
42 Contributors
Updated on 28 Oct 2024
Minified
Minified + Gzipped
JavaScript (88.62%)
Shell (10.82%)
Python (0.57%)
Cumulative downloads
Total Downloads
Last day
-13.5%
37,958
Compared to previous day
Last week
4.3%
237,399
Compared to previous week
Last month
-0.4%
945,619
Compared to previous month
Last year
6.3%
13,468,435
Compared to previous year
4
22
Create private keys and certificates with node.js
Install with npm
npm install pem
or use yarn
yarn add pem
:warning: Please make sure you have openssl
or libressl
already installed on your system/container, without
them pem
will not work.
Here are some examples for creating an SSL key/cert on the fly, and running an HTTPS server on port 443. 443 is the standard HTTPS port, but requires root permissions on most systems. To get around this, you could use a higher port number, like 4300, and use https://localhost:4300 to access your server.
1var https = require('https') 2var pem = require('pem') 3 4pem.createCertificate({ days: 1, selfSigned: true }, function (err, keys) { 5 if (err) { 6 throw err 7 } 8 https.createServer({ key: keys.clientKey, cert: keys.certificate }, function (req, res) { 9 res.end('o hai!') 10 }).listen(443) 11})
1var https = require('https') 2var pem = require('pem') 3var express = require('express') 4 5pem.createCertificate({ days: 1, selfSigned: true }, function (err, keys) { 6 if (err) { 7 throw err 8 } 9 var app = express() 10 11 app.get('/', function (req, res) { 12 res.send('o hai!') 13 }) 14 15 https.createServer({ key: keys.clientKey, cert: keys.certificate }, app).listen(443) 16})
Please have a look into the API documentation.
we had to clean up a bit
You can specify custom OpenSSL extensions using the config
or extFile
options for createCertificate
(or using csrConfigFile
with createCSR
).
extFile
and csrConfigFile
should be paths to the extension files. While config
will generate a temporary file from the supplied file contents.
If you specify config
then the v3_req
section of your config file will be used.
The following would be an example of a Certificate Authority extensions file:
[req]
req_extensions = v3_req
distinguished_name = req_distinguished_name
[req_distinguished_name]
commonName = Common Name
commonName_max = 64
[v3_req]
basicConstraints = critical,CA:TRUE
While the following would specify subjectAltNames in the resulting certificate:
[req]
req_extensions = v3_req
[ v3_req ]
basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
subjectAltName = @alt_names
[alt_names]
DNS.1 = host1.example.com
DNS.2 = host2.example.com
DNS.3 = host3.example.com
Note that createCertificate
and createCSR
supports the altNames
option which would be easier to use in most cases.
:warning: Warning: If you specify altNames
the custom extensions file will not be passed to OpenSSL.
In some systems the openssl
executable might not be available by the default name or it is not included in $PATH. In this case you can define the location of the executable yourself as a one time action after you have loaded the pem module:
1var pem = require('pem') 2pem.config({ 3 pathOpenSSL: '/usr/local/bin/openssl' 4}) 5// do something with the pem module
For more details, search in test/pem.spec.js
: Create CSR with specialchars config file
If you use special chars like:
-!$%^&*()_+|~=`{}[]:/;<>?,.@#
You should know that the result mey have escaped characters when you read it in your application. Will try to fix this in the future, but not sure.
MIT
The latest stable version of the package.
Stable Version
1
7.5/10
Summary
Sensitive Data Exposure in pem
Affected Versions
< 1.13.2
Patched Versions
1.13.2
Reason
security policy file detected
Details
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
3 existing vulnerabilities detected
Details
Reason
Found 5/9 approved changesets -- score normalized to 5
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More