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

wedeploy-letsencrypt

v2.0.3

Published

CLI and API for issuing, renewing and revoking certificates on user's behalf using Let's Encrypt

Downloads

11

Readme

Install

$ npm i --save wedeploy-letsencrypt

If you prefer to install it globally and use the CLI, use the following command:

$ npm i -g wedeploy-letsencrypt

Then, the command wel should be available in PATH. Run wel --help for more information about the available options.

Usage

Using as CLI

$ wel <cmd> [args]

Commands:
  certonly  Issue/renew certificate(s)
  renew     Renew certificate(s)

Options:
  --help         Show help                                                                                     [boolean]
  -v, --version  Show version number                                                                           [boolean]

The options for certonly and renew commands are the same and they are:

Options:
  --help                Show help                                                                              [boolean]
  --account-key-path    Path to privkey.pem to use for account (default: generate new)                          [string]
  --agree-tos           Agree to the Let's Encrypt Subscriber Agreement.                                      [required]
  --cert-path           Path to where new cert.pem is saved.    [string] [default: ":configDir/live/:hostname/cert.pem"]
  --chain-path          Path to where new chain.pem is saved.  [string] [default: ":configDir/live/:hostname/chain.pem"]
  --config-dir          Configuration directory.                                [string] [default: "~/letsencrypt/etc/"]
  --debug               Show traces and logs.                                                 [boolean] [default: false]
  --domains             Domain names to apply. For multiple domains use space separated list of domains as a parameter.
                                                                                                      [array] [required]
  --domain-key-path     Path to privkey.pem to use for domain (default: generate new)                           [string]
  --duplicate           Allow getting a certificate that duplicates an existing one/is an early renewal.
                                                                                              [boolean] [default: false]
  --email               Email used for registration and recovery contact.                            [string] [required]
  --fullchain-path      Path to where new fullchain.pem (cert + chain) is saved.
                                                           [string] [default: ":configDir/live/:hostname/fullchain.pem"]
  --http-01-port        Use HTTP-01 challenge type with this port.                                [number] [default: 80]
  --key-fullchain-path  Path to where key + fullchain.pem is saved.
                                                        [string] [default: ":configDir/live/:hostname/keyfullchain.pem"]
  --renew-within        Renew certificates this many days before expiry.                           [number] [default: 7]
  --rsa-key-size        Size (in bits) of the RSA key.                                          [number] [default: 2048]
  --server              ACME Directory Resource URI. Default: staging server. Use "production" to connect to the
                        production server.      [string] [choices: "https://acme-staging.api.letsencrypt.org/directory",
                         "https://acme-v01.api.letsencrypt.org/directory", "staging", "production"] [default: "staging"]
  --webroot-path        public_html / webroot path.                               [string] [default: "/var/lib/haproxy"]
  -v, --version         Show version number                                                                    [boolean]

To issue a certificate for a domain, you may use the following command:

$ wel certonly --agree-tos --domains example.com www.example.com --email [email protected] --config-dir ~/cfg-dir --server staging --webroot-path /var/lib/haproxy

The command will validate the example.com and www.example.com using HTTP challenge and register or renew a certificate for it. The server (HAProxy for example) should be able to serve files from /var/lib/haproxy directory.

To renew a certificate for a domain, you may use the following command:

$ wel renew --agree-tos --domains example.com www.example.com --email [email protected] --config-dir ~/cfg-dir --server staging --webroot-path /var/lib/haproxy

If --duplicate is not specified and there is no certificate to be renewed, an exception will be thrown with a code property which value will be E_NOT_RENEWABLE.

Using as API

In an application, require WeDeploy Let's Encrypt implementation and call generateCertificate method, passing configuration options as properties of an object. The function returns a Promise, which will be fulfilled with the registered certificates. The certificates will be stored to the configuration directory (configDir property) already. The list of available options are the same as those, which could be specified from the command line, but in camelCase. For example, agree-tos should become agreeTos and rsa-key-size should become rsaKeySize.

Example code for generating a certificate:

const LetsEncrypt = require('wedeploy-letsencrypt');

LetsEncrypt.generateCertificate(options)
  .then((certs) => {
    console.log('Got certificate(s) for', certs.altnames.join(', '));
  })
  .catch((error) => {
    console.error(error);
  });

Example code for renewing a certificate:

const LetsEncrypt = require('wedeploy-letsencrypt');

LetsEncrypt.renewCertificate(options)
  .then((certs) => {
    console.log('Got certificate(s) for', certs.altnames.join(', '));
  })
  .catch((error) => {
    console.error(error);
  });

Test

$ npm test

License

BSD License © Liferay, Inc.