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

acme-express

v0.2.4

Published

ACME protocol client for SSL certificates

Downloads

6

Readme

acme-express

Automatic Certificate Management Environment (ACME) protocol client for acquiring free SSL certificates.

Letsencrypt.org is a gratis, open source community sponsored service that implements the ACME protocol. This script will allow you to create a signed SSL certificate, suitable to secure your server with HTTPS, using letsencrypt.org or any other certificate authority that supports the ACME protocol.

Installation

  npm install -g acme-express

CLI

  Usage: acme-express --account account.pem --csr csr.der --domain ${DOMAIN} --ca letsencrypt-beta

  Options:

    -h, --help                                           output usage information
    --account <account.pem>                              Account private key PEM file
    --csr <csr.der>                                      Certificate Signing Request file in DER encoding
    --dom <domain>                                       The domain for which we are requesting a certificate. e.g. "mydomain.org"
    --ca <URL|"letsencrypt-beta"|"letsencrypt-staging">  Certificate authority URL running ACME protocol. Default "letsencrypt-staging"
    --agreement <URL|"letsencrypt-1.0.1">                The certificate agreement URL. Default "letsencrypt-1.0.1"
    --log <debug|info|warn|error>                        Set the log level (logs always use STDERR). Default "info"
    --cross-signed                                       Print letsencrypt.org's cross-signed x1 cert to STDOUT

How to Use

  1. Register a domain and point your DNS at your server.
  2. From that server, use this script to verify that you control the domain and acquire a signed certficate.

Sign a Cert

  # Set your domain
  DOMAIN=mydomain.org

  # Create domain key and DER encoded Certificate Signing request
  openssl genrsa 4096 > domain.pem
  openssl req -new -sha256 -key domain.pem -subj "/CN=${DOMAIN}" -outform DER > csr.der

  # Create account key and get letsencrypt.org to sign your cert
  openssl genrsa 4096 > account.pem
  sudo acme-express --account account.pem --csr csr.der --dom "${DOMAIN}" --ca letsencrypt-beta > ${DOMAIN}.pem

  # (Optional) Examine your new certificate
  openssl x509 -in ${DOMAIN}.pem -text

Why Sudo?

To verify ownership of the domain, we use the simple HTTP challenge/response method. This script will briefly host a Node.js HTTP server on port 80 (which requires admin access). The challenge token is served at the well-defined challenge/response URL so that the certificate authority can request it.

See the "challengeResponse" method in src/acme-protocol.coffee

Create an HTTPS Server

Here is an example Node.js express server using a certificate produced by this script:

  let fs      = require('fs');
  let http    = require('http');
  let https   = require('https');
  let express = require('express');
  let app     = express();
  let domain  = 'mydomain.org';

  // Load the HTTPS credentials
  let credentials = {
    key  : fs.readFileSync('domain.pem'),
    cert : fs.readFileSync(domain + '.pem'),

    // If you want to get an 'A' on your ssllabs report card, you need to
    // include the cross-signed cert from letsencrypt.org. Download it
    // directly from letsencrypt.org at the following URL:
    //   https://letsencrypt.org/certs/lets-encrypt-x1-cross-signed.pem
    ca   : [fs.readFileSync('lets-encrypt-x1-cross-signed.pem')]
  }

  // Create an HTTPS server with your express app
  https.createServer(credentials, app).listen(443, function() {
    console.log('Listening on HTTPS');
  });

  // (Optional) Create a simple server to redirect all HTTP traffic to HTTPS
  http.createServer(function (req, res) {
    let code = (req.method === 'POST') ? 307 : 302;
    res.writeHead(code, {'Location' : 'https://' + domain + req.url});
    res.end();
  }).listen(80, function() {
    console.log('Redirecting HTTP to HTTPS');
  });