Configuring Acme-client

To enable TLS, you will want a certificate signed by a trusted certificate authority (CA). In this guide, we'll use OpenBSD's acme-client with Let's Encrypt.


TLS (Transport Layer Security) aka SSL (Secure Sockets Layer) is the encryption security measure that enables browsers to recognize a website as "secure". In modern browsers the SSL information can be accessed by clicking the padlock icon in the address bar.

SSL certificates are obtained from CAs (Certificate Authorities). Currently, the only free CAs are Lets Encrypt, Buypass and ZeroSSL. You can request an SSL cert for your web domain using an Automatic Certificate Management Environment (ACME) client such as OpenBSD's Acme-client, which we will configure in this article.

Before You Begin

You will first need to properly configure and start openhttpd. You will also need properly functioning DNS records for your hostname ( If you are using a training vps, it is likely that DNS records for your hostname have already been set up for you.

You can and should test the two configurations using host and netcat.

Note: You must have a server block in /etc/httpd.conf listening on port 80. Do not delete this block or else acme-client will not work.


First, copy the acme-client.conf template:

$ doas cp /etc/examples/acme-client.conf /etc/acme-client.conf

We'll open up /etc/acme-client.conf and analyze the meaning of each block:

Authority blocks

authority letsencrypt {
        api url ""
        account key "/etc/acme/letsencrypt-privkey.pem"

This defines the Certificate Authority letsencrypt. It provides the API URL and the location of the account key.

Note: Let's Encrypt rate-limits the number of SSL certs you can request. If you encounter an error and are unable to request an SSL cert, please fix all errors before requesting again. If you request too many certs in a short time, your domain will get blacklisted for a few hours or days. To avoid issues, use letsencrypt-staging first and make sure you get success with that before using letsencrypt.

Although we are using Let's Encrypt for this tutorial, it is important to note that having the majority of servers depend upon a single provider is dangerous. For this reason, it would be beneficial to someday have the community run its own Certificate Authority to avoid censorship of domains or other security issues.

authority letsencrypt-staging {
        api url ""
        account key "/etc/acme/letsencrypt-staging-privkey.pem"

letsencrypt-staging is a staging server which you can use to practice requesting fake certificates. The rate limits for the staging server are less strict, so you should practice first with this CA.

To both of these blocks, we will want to add our contact email, so we add contact "" inside both blocks. (make sure to have the mailto:):

authority letsencrypt {
        api url ""
        account key "/etc/acme/letsencrypt-privkey.pem"
        contact ""

authority letsencrypt-staging {
        api url ""
        account key "/etc/acme/letsencrypt-staging-privkey.pem"
        contact ""

Next, the default acme-client.conf defines two more authorities:

authority buypass {
        api url ""
        account key "/etc/acme/buypass-privkey.pem"
        contact ""

authority buypass-test {
        api url ""
        account key "/etc/acme/buypass-test-privkey.pem"
        contact ""

These two blocks are the same as for letsencrypt, but with the alternative provider buypass. Make sure to replace the contact email with your own email.

Domain Block

domain {
        alternative names { }
        domain key "/etc/ssl/private/"
        domain full chain certificate "/etc/ssl/"
        sign with letsencrypt

First, replace every appearance of with your own domain.

Each SSL cert is valid only for a common name and a set of alternative names that are provided on the certificate. For example, an SSL certificate might have the common name and the alternative names and You can safely skip this by commenting out this line (see warning below)

If you use too many alternative names, an acme-client certificate request has a higher chance of failure. So, we recommend keeping the number of alternative names to under 5.

Warning: Having the alternative names directive with nothing inside will cause errors. For example, the below will cause errors:

alternative names { }

If you don't need any alternative names, you should comment this line out by putting a # at the beginning of the line, like so:

#        alternative names { }

Note: If you add an alternative name to the conf file, but the cert already exists, you must remove the old public cert first before requesting a new one. Otherwise, you will get unknown SAN error -- acme-client will complain there is an unknown Subject Alternative Name.

Next, the domain key and domain full chain certificate tell acme-client where to put the private key and certificate:

        domain key "/etc/ssl/private/"
        domain full chain certificate "/etc/ssl/"

The public key goes inside the folder /etc/ssl and the private key goes inside /etc/ssl/private.

The line sign with letsencrypt line tells Acme-client which Certificate Authority (which you defined in the Authority Blocks) to use.

For testing purposes, you may want to change it to letsencrypt-staging. You can also consider using buypass or buypass-test.

Note: staging or testing certificates are not recognized by most browsers and will be rejected as an invalid certificate. After you finish testing with a staging certificate, change this line back to an official authority (such as sign with letsencrypt).

Requesting Certificates

After you have finished configuring the conf file, we can request certificates:

$ doas acme-client -Fv

If there are no errors, you should see something similar to the following output:

$ doas acme-client -Fv
acme-client: /etc/acme/letsencrypt-privkey.pem: generated RSA account key
acme-client: /etc/ssl/private/ generated RSA domain key
acme-client: directories
acme-client: DNS:
acme-client: dochngreq:
acme-client: challenge, token: uWHZmqhx6NEpcv25LEvodMAeymB1guTFVtyktVzkJgs, uri:, status: 0
acme-client: /var/www/acme/uWHZmqhx6NEpcv25LEvodMAeymB1guTFVtyktVzkJgs: created
acme-client: challenge
acme-client: order.status 0
acme-client: dochngreq:
acme-client: challenge, token: uWHZmqhx6NEpcv25LEvodMAeymB1guTFVtyktVzkJgs, uri:, status: 2
acme-client: order.status 1
acme-client: certificate
acme-client: order.status 3
acme-client: certificate
acme-client: /etc/ssl/ created

The last line says that the public certificate was generated. If you see that, it's a success!

You now have two certificates, the public key inside /etc/ssl/, and the private key inside /etc/ssl/private/

$ doas ls -l /etc/ssl/ /etc/ssl/private/
-r--r--r--  1 root  wheel  4797 Feb 25 02:11 /etc/ssl/
-r--------  1 root  wheel  3272 Feb 25 02:10 /etc/ssl/private/


Let's Encrypt TLS certs expire after 90 days, while Buypass certs expire after 180. For both, you must remember to request the TLS cert or TLS will stop working. To avoid forgetting, we can automate the request process using crontab.

$ doas crontab -e

Add this line at the bottom:

~       ~       *       *       *       acme-client >> /var/log/acme-client.log 2>&1

This cronjob will check the certificate once each day, at a random time of day, to see if it needs to be renewed. If it does, it will renew the cert.


If acme-client fails, there are several possible causes:

Domain Not Listed

If you add a new alternative name inside your domain block in /etc/acme-client.conf, you will see this error:

acme-client: /etc/ssl/ domain not listed:

Here, was a new alternative name you added. The solution is to move your old public cert and private key to a new location (to back it up). Then, request the cert again.

$ doas mv /etc/ssl/ /etc/ssl/
$ doas mv /etc/ssl/private/ /etc/ssl/private/

Then request the cert again:

$ doas acme-client -Fv

Missing Domain Records

It's possible that your domain records are missing. Run this command, replacing with your real hostname:

$ host

You should see one or two records like the following: has address has IPv6 address 2606:2800:220:1:248:1893:25c8:1946

If you have missing records, you will see this response:

Host not found: 3(NXDOMAIN)

You will either need to speak with your DNS provider or troubleshoot nsd. If DNS records are missing or incorrect, fix these first.

The IPv4 and IPv6 address must exactly match the IPs that OpenHTTPd is listening on. If they do not match, you must fix this.

Note: You cannot request a domain you don't own! The domain must point to an IP you own.

Lastly, if your DNS record includes an IPv6 address, make sure your web server is listening on IPv6. If the DNS record contains an IPv4 address, make sure your web server is listening on IPv4.

OpenHTTPd Misconfigured

If openhttpd is not configured and running properly, acme-client won't work.

(acme-client uses the "http-01" challenge. A file is created with a special message in /var/www/acme/, and the certificate authority requests that file using the URL*. )

To test if your web server is running properly, use telnet (replacing with your domain) on another computer.

$ telnet 80
GET /index.html HTTP/1.1

If you do not get the correct response, double check your openhttpd configuration.

Note: Although a web browser can also be used for testing, many web browsers automatically forward all port 80 requests to port 443. As a result, your web browser will only see what is listening on port 443, whereas the certificate authority tests port 80 only.

Incorrect File Permissions

Double check /var/www and /var/www/acme for correct file permissions:

$ ls -ld /var/www /var/www/acme
drwxr-xr-x  10 root  daemon  512 Oct  5 07:47 /var/www
drwxr-xr-x   2 root  daemon  512 Oct  5 07:47 /var/www/acme

See Also:

Configure OpenHTTPdConfigure HTTPd
Telnet HTTPUse Telnet to Troubleshoot HTTP
OpenSSL HTTPUse OpenSSL to Troubleshoot HTTPS