Setting up Dehydrated

challenge types http-01 and dns-01

Introduction

we want to allow legacy/non-ECC SSL clients (e.g. slackware.com and orange.fr outbound MTAs) to connect so we’re keeping RSA as a default. However we’re also providing ECDSA as an alternative with far more ciphers to offer as a result.

Install

binaries

apt install dehydrated
#dehydrated-apache2

from source

git clone https://github.com/lukas2511/dehydrated.git

ls -lhF /usr/local/bin/dehydrated #noexist
cp dehydrated/dehydrated /usr/local/bin/
dehydrated -h

HTTP-01 challenge

mkdir -p /etc/dehydrated/
vi /etc/dehydrated/config

IP_VERSION=4
CA="https://acme-v02.api.letsencrypt.org/directory"
CHALLENGETYPE="http-01"
WELLKNOWN="/var/www/dehydrated"
#WELLKNOWN="/var/www/html/.well-known/acme-challenge"
CONTACT_EMAIL=...

#KEY_ALGO=prime256v1
#KEY_ALGO=secp384r1
#KEY_ALGO=rsa

vi /etc/dehydrated/domains.txt

DOMAIN.TLD
HOST.DOMAIN.TLD
OTHERDOMAIN.TLD

prepare the shared folder for HTTP-01 challenges

mkdir -p /var/www/dehydrated/
echo ok > /var/www/dehydrated/ok.txt
#mkdir -p /var/www/html/.well-known/acme-challenge/
#echo ok > /var/www/html/.well-known/acme-challenge/ok.txt

this goes in conjunction with an all vhosts setting we define in nginx.conf.

check remotely that you are well known on the clear-text web

from your workstation

curl -I http://pub.nethence.com/.well-known/acme-challenge/ok.txt

DNS-01 challenage

assuming you’ve got NSD up and running locally

cd /root/
#wget https://raw.githubusercontent.com/dehydrated-io/dehydrated/master/docs/examples/hook.sh
#wget https://raw.githubusercontent.com/sebastiansterk/dns-01-manual/master/hook.sh
wget https://pub.nethence.com/bin/daemons/hook.sh.txt
mv hook.sh.txt hook.sh
chmod +x hook.sh

we are pointing to our hook script here

vi /etc/dehydrated/config-dns01

IP_VERSION=4
CA="letsencrypt"
CHALLENGETYPE="dns-01"
DOMAINS_TXT="${BASEDIR}/domains-dns01.txt"
HOOK=/root/hook.sh
CONTACT_EMAIL=...

grab some certs for both, the domain itself and its sub-level wildcard

vi /etc/dehydrated/domains-dns01.txt

DOMAIN.TLD
*.DOMAIN.TLD > DOMAIN_TLD

Ready to go

accept the terms and attempt to get some CSR signed

    dehydrated --register --accept-terms
    find /etc/dehydrated/accounts/
    cd /etc/ssl/

make a specific folder available for the ECC flavor of your certs

mkdir -p /etc/dehydrated/certs/ECC/

dealing with http-01

dehydrated --cron
dehydrated --cron --algo prime256v1 --out /etc/dehydrated/certs/ECC
dehydrated --cleanup

dealing with dns-01

dehydrated --cron --config /etc/dehydrated/config-dns01
dehydrated --cron --config /etc/dehydrated/config-dns01 --algo secp384r1 --out /etc/dehydrated/certs/ECC
dehydrated --cleanup

other options

# --force

You are now ready to use those CA-signed certs with e.g. NGINX, Postfix and Dovecot.

Automation

tested with nginx postfix dovecot

DON’T FORGET TO RELOAD THE DAEMONS. Yes, just a reload is enough.

vi /root/RELOAD-SSL

#!/bin/bash

/usr/local/sbin/nginx -s reload && echo nginx reloaded

# self-verbose
/usr/sbin/postfix reload

/usr/sbin/dovecot reload && echo dovecot reloaded

chmod +x /root/RELOAD-SSL

and simply run the thing in a cron job ONCE A WEEK

    crontab -e

    MINUTE HOUR * * 0 /root/WEEKLY 2>&1

vi /root/WEEKLY

echo RE-NEWING RSA CERTIFICATES
echo
#dehydrated --cron --keep-going
dehydrated --cron --config /etc/dehydrated/config-dns01
echo

echo RE-NEWING ECDSA CERTIFICATES
echo
#dehydrated --cron --keep-going --algo prime256v1 --out /etc/dehydrated/certs/ECC
dehydrated --cron --config /etc/dehydrated/config-dns01 --algo secp384r1 --out /etc/dehydrated/certs/ECC
echo

echo RELOADING DAEMONS
echo
/root/RELOAD-SSL
echo

echo CLEANING-UP UNUSED CERTS
dehydrated --cleanup
echo

echo +x /root/WEEKLY

Note we’re using --keep-going only for the HTTP-01 sample.

Note we’re cleaning-up AFTER having reloaded the daemons.

Additional notes

dealing with a self-defined curve

    dehydrated --signcsr $domain.csr --full-chain > $domain.crt

Resources

dehydrated https://github.com/dehydrated-io/dehydrated

Dehydrated: a bash client for Let’s Encrypt https://www.aaflalo.me/2016/09/dehydrated-bash-client-lets-encrypt/

WELLKNOWN https://github.com/lukas2511/dehydrated/blob/master/docs/wellknown.md

WELLKNOWN documentation gives conflicting statements #193 https://github.com/lukas2511/dehydrated/issues/193

Dehydrated и Let’s Encrypt https://sysadmin.pm/dehydrated-letsencrypt/

I can not renew a certificate (dehydrated) https://community.letsencrypt.org/t/i-can-not-renew-a-certificate-dehydrated/77487

dns-01

Home https://github.com/dehydrated-io/dehydrated/wiki

dehydrated/docs/examples/domains.txt https://github.com/dehydrated-io/dehydrated/blob/master/docs/examples/domains.txt

dns-01 challenge https://github.com/dehydrated-io/dehydrated/blob/master/docs/dns-verification.md

example dns 01 nsupdate script https://github.com/dehydrated-io/dehydrated/wiki/example-dns-01-nsupdate-script

https://serverfault.com/questions/750902/how-to-use-lets-encrypt-dns-challenge-validation

https://community.letsencrypt.org/t/dns-01-problem-with-dehydrated/116338

https://www.aaflalo.me/2017/02/lets-encrypt-with-dehydrated-dns-01/

https://blog.znedw.com/lets-encrypt-wildcard-nsd.html

acme v2

ACME v2 Support #420 https://github.com/dehydrated-io/dehydrated/issues/420


GUIDES | LECTURES | BENCHMARKS | SMTP HEALTH