Clojure
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
resources
src/certificaat
CHANGELOG.org
README.org
boot.properties
build.boot

README.org

Certificaat

Definition

Certificaat is a general-purpose ACME client, fully compatible with the Let’s Encrypt CA.

Motivation

Certificaat’s aim is to help you retrieve a certificate for your domain, and subsequently help you set up a cron job and forget about it.

Note: If certbot does everything for everybody, Certificaat is narrower in scope, focusing on usability and automated renewals.

Installation

Download the latest release, extract the archive and drop the self-contained binary in your PATH.

Note: Java is a system requirement.

Usage

Command line

To get a certificate for a domain, you need to initialize certificaat with said domain, then you run it repeatedly until your certificate has downloaded.

  1. certificaat -m change.me init
  2. certificaat -m change.me run

The certificate can be renewed in one pass with certificaat -m change.me cron.

Init

certificaat -m change.me init

The -m option indicates the domain you want to authorize. It will feature in the Subject name of the final X.509 certificate.

certificaat -m change.me -n www.change.me init

The -n option is for additional domain name you want to authorize. It will feature in the Subject Alternative Name a(SAN) of the certificate. Repeat this option for all required names. Caution: there is a hard limit imposed by the CA.

During this phase, certificaat will, if needed, register a user account with the ACME CA, and write configuration files that you then can edit and customize.

Certificaat follows the XDG Base Directory Specification. The configuration folder is determined by querying the value of XDG_CONFIG_HOME in the environment, and if not set, will default to $HOME/.config/certificaat.

Configuration files are in edn format and can be edited in any text editor.

The local configuration file is stored in the project directory, $HOME/.config/certificaat/change.me/config.edn , and looks like this:

{:acme-uri "acme://letsencrypt.org/staging",
 :challenges #{"http-01"},
 :contact "mailto:admin@change.me",
 :domain "change.me",
 :hooks [:before-challenge :after-request],
 :organisation "ChangeMe corporation",
 :san #{"www.change.me"}}

Hopefully, the options are self-explanatory.

  • the email address used by the CA to send expiry reminders.
  • the challenge you want to complete. If you want to offer the CA multiple challenges, that is supported as well.
  • the URI to the ACME CA. By default, Certificaat will talk to Let’s Encrypt’s staging server. The resulting certificates will be fake. This is so you can practice until you are ready to issue a production certificate.
Staging URIProduction URI
acme://letsencrypt.org/stagingacme://letsencrypt.org

The global configuration is stored in the root directory, $HOME/.config/certificaat/change.me/config.edn and it looks like this:

{:key-size 2048,
 :key-type :rsa,
 :keypair-filename "account.key",
 :plugins {:diffie-hellman {:enabled false,
                            :filename "dhparam.pem",
                            :group14 true,
                            :modulus 2048},
           :email {:enabled false,
                   :sendmail false,
                   :smtp {:host "smtp.changeme.org",
                          :pass "changeme",
                          :port 587,
                          :user "changeme"}},
           :webroot {:enabled false, :path "/var/www/"}}}

Run

certificaat -m change.me run 

certificaat will display instructions pertaining to the challenge. This is the time to satisfy the requirements (for example, configuring DNS records or preparing your web server). When you are ready, simply repeat the operation and the challenges will be triggered and, if successfully completed, a certificate downloaded and saved to disk.

Hooks

Hooks are provided to perform additional functionality at key moments, namely before the challenges get triggered, and after a certificate has been acquired or renewed. The hooks are powered by plugins that need to be configured and enabled.

The plugin configuration resides in the root directory, XDG_CONFIG_HOME/.config/certificaat/config.edn

Webroot

This enables authorizing and requesting the certificate in a single pass.

Email

An email will be sent to the contact registered with the certificate.

Diffie-Helman parameters

This will save a Diffie-Helman parameters file along with the certificate, for further tuning the SSL setup.

Info

certificaat -m example.com info

Certificaat will display a summary of the certificate.

Renew

certificaat -m example.com cron

This command can be integrated in an automated workflow. For example, as a cron job.

5 8 1 * * certificaat -m change.me cron && /usr/sbin/service nginx reload

Challenges

Certificaat will honor all challenges defined in the ACME specification, but please note that Let’s Encrypt CA does not support the OOB challenge and that TLS-SNI comes in two flavors.

ChallengeOption identifierLet’s EncryptCertificaat
HTTPhttp-01
DNSdns-01
TLS with Server Name Indication (SNI)tls-sni-01 & tls-sni-02✓ & ✕
Out-of-Bandoob-01

Clojure library

In addition to the command line, Certificaat is available on Clojars as a regular Clojure library which you can require in your projects.

http://clojars.org/org.danielsz/certificaat/latest-version.svg

Note: a single namespace exposes a core API which is made available to all interfaces.

Contributions

If you plan to submit enhancements beyond bug fixes, please coordinate with me beforehand in order to save everybody’s time and effort.

Credits

I wish to thank Richard Körber who wrote the Java client for the ACME protocol, acme4j, which serves as the foundation for Certificaat. Not only is it well written, it is exquisitely documented.

License

Licensing terms will be revealed shortly. In the meantime, do what you want with it. Type certificaat -h to familiarize yourself with the input it expects. For as long as the authorizations remain valid,

Note: With LetsEncrypt, cached authorizations last for 30 days from the time of validation.