Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@small-tech/auto-encrypt-localhost
Advanced tools
Automatically provision and use locally-trusted TLS certificates in Node.js using mkcert.
Automatically provisions trusted localhost TLS certificates via mkcert for development without browser security warnings in Node.js.
npm i @small-tech/auto-encrypt-localhost
// Create an https server using locally-trusted certificates.
const https = require('https')
const autoEncryptLocalhost = require('@small-tech/auto-encrypt-localhost')
const server = https.createServer(autoEncryptLocalhost(), (request, response) => {
response.end('Hello, world!')
})
server.listen(() => {
console.log('Web server is running at https://localhost')
})
PS. You can find this example in the example/ folder in the source code. Run it by typing node example
.
Small Technology Foundation is a tiny, independent not-for-profit.
We exist in part thanks to patronage by people like you. If you share our vision and want to support our work, please become a patron or donate to us today and help us continue to exist.
This is small technology.
If you’re evaluating this for a “startup” or an enterprise, let us save you some time: this is not the right tool for you. This tool is for individual developers to build personal web sites and apps for themselves and for others in a non-colonial manner that respects the human rights of the people who use them.
Auto Encrypt Localhost is a Node.js wrapper for mkcert that:
Uses the 64-bit release binaries to support Linux, macOS, and Windows.
Automatically installs the certutil (nss) dependency on Linux on systems with apt, pacman, yum (untested) and and on macOS if you have Homebrew or MacPorts (untested).
Creates a root Certificate Authority
Creates locally-trusted TLS certificates for localhost, 127.0.0.1, and ::1
You can use these certificates for local development without triggering self-signed certificate errors.
For more details on how Auto Encrypt Localhost works behind the scenes, please see the mkcert README.
Auto Encrypt Localhost is exported as a function that accepts an optional parameter object with optional options
and settingsPath
properties. The defaults for both are shown below.
autoEncryptLocalhost({ options: {}, settingsPath: '~/.small-tech.org/auto-encrypt-localhost' })
Auto Encrypt Localhost generates a locally-trusted private key and certificate using mkcert and then loads them in and returns an options object that you can pass directly to the https.createServer()
method. If you want to pass other options to the server while creating it, just pass your regular options object to Auto Encrypt Localhost wrapped in a parameter object as shown below.
const options = { /* your other https server options go here */ }
const server = https.createServer(autoEncryptLocalhost({ options }), (request, response) => {
response.end('Hello, world!')
})
By default, Auto Encrypt Localhost creates and uses the ~/.small-tech.org/auto-encrypt-localhost directory as its settings path, to store your certificate and its private key. You can tell it to use a different path instead by specifying the path to use in the settingsPath
property of its parameter object.
const os = require('os')
const path = require('path')
const settingsPath = path.join(os.homedir(), '.my-namespace', 'magic-localhost-certificates')
const server = https.createServer(autoEncryptLocalhost({ settingsPath }), (request, response) => {
response.end('Hello, world!')
})
In the above example, your certificate and its private key will be stored in the ~/.my-namespace/magic-localhost-certificates directory (with the names localhost.pem and localhost-key.pem, respectively).
npm i -g @small-tech/auto-encrypt-localhost
auto-encrypt-localhost
Your certificates will be created in the ~/.small-tech.org/auto-encrypt-localhost directory.
Locally-trusted certificates do not work under Firefox. Please use Edge or Chrome on this platform. This is a mkcert limitation
From lower-level to higher-level:
Automatically provisions and renews Let’s Encrypt™ TLS certificates for Node.js® https servers (including Express.js, etc.)
A drop-in standard Node.js https
module replacement with both automatic development-time (localhost) certificates via Auto Encrypt Localhost and automatic production certificates via Auto Encrypt, see @small-tech/https.
A complete small technology tool to develop, test, and deploy a secure static or dynamic personal web site or app with zero configuration.
Small Technology Foundation is a tiny, independent not-for-profit.
We exist in part thanks to patronage by people like you. If you share our vision and want to support our work, please become a patron or donate to us today and help us continue to exist.
Copyright © Aral Balkan, Small Technology Foundation.
Auto Encrypt Localhost is released under AGPL 3.0 or later.
FAQs
Automatically provisions and installs locally-trusted TLS certificates for Node.js https servers in 100% JavaScript.
The npm package @small-tech/auto-encrypt-localhost receives a total of 772 weekly downloads. As such, @small-tech/auto-encrypt-localhost popularity was classified as not popular.
We found that @small-tech/auto-encrypt-localhost demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.