Installation:
pkg install acme.sh
Configuration is in:
/var/db/acme/.acme.sh/account.conf
Certificates are stored in
/var/db/acme/certs/
As the certificates are only accessible by user acme, we need to do an additional step to make the certificates available to dovecot/postfix/haproxy.
As next we configure log rotation:
cp /usr/local/share/examples/acme.sh/acme.sh.conf /usr/local/etc/newsyslog.conf.d/
Make sure you uncomment the line in /usr/local/etc/newsyslog.conf.d/acme.sh.conf:
/var/log/acme.sh.log acme:acme 640 90 * @T00 BC
Next is to configure cron to automatically renew your certificates. For this we edit /etc/crontab
# Renew certificates created by acme.sh
MAILTO="idefix"
7 2 * * * acme /usr/local/sbin/acme.sh --cron --home /var/db/acme/.acme.sh > /dev/null
We need to create the logfile:
touch /var/log/acme.sh.log
chown acme /var/log/acme.sh.log
Allow acme to write the challenge files:
mkdir -p /usr/local/www/letsencrypt/.well-known/
chgrp acme /usr/local/www/letsencrypt/.well-known/
chmod g+w /usr/local/www/letsencrypt/.well-known/
Setup configuration of acme.sh:
echo ACCOUNT_EMAIL=\"name@yourdomain.tld\" >> account.conf
Hook the own custom deploy scripts from: https://gitlab.fechner.net/mfechner/letsencrypt_hooks Make sure you create a config file and now symlink the hook:
cd /var/db/acme/.acme.sh/deploy
ln -s /usr/home/idefix/letsencrypt/create-haproxy-ssl-restart-all_acme.sh
Now we can create our first test certificate (run this as root):
su -l acme -c "cd /var/db/acme && acme.sh --issue --test -k ec-256 -w /usr/local/www/letsencrypt -d beta.fechner.net -d vmail2.fechner.net -d smtp2.fechner.net --deploy-hook create-haproxy-ssl-restart-all_acme"
su -l acme -c "cd /var/db/acme && acme.sh --issue --test -k 2048 -w /usr/local/www/letsencrypt -d beta.fechner.net -d vmail2.fechner.net -d smtp2.fechner.net --deploy-hook create-haproxy-ssl-restart-all_acme"
If everything is fine, you can get the real certificates with:
su -l acme -c "cd /var/db/acme && acme.sh --issue -k ec-256 -w /usr/local/www/letsencrypt -d beta.fechner.net -d vmail2.fechner.net -d smtp2.fechner.net --deploy-hook create-haproxy-ssl-restart-all_acme --server letsencrypt --force"
su -l acme -c "cd /var/db/acme && acme.sh --issue -k 2048 -w /usr/local/www/letsencrypt -d beta.fechner.net -d vmail2.fechner.net -d smtp2.fechner.net --deploy-hook create-haproxy-ssl-restart-all_acme --server letsencrypt --force"
Now you should find an RSA and a ECDSA certificate in:
/var/db/acme/certs
As we will renew certificates of many domains, but tools like dovecot/postfix/haproxy need a directory or a single file we need to prepare these files and copy them with correct permissions to destination folders.
Add a new subdomain
You have already a certificate for vmail2.fechner.net
and would like now to add more hosts to it.
Go to folder:
cd /var/db/acme/certs/vmail2.fechner.net_ecc
And add a new line to vmail2.fechner.net.conf
or just attach a new subdomain seperated by comma:
Le_Alt='oldhost.fechner.net,newhost.fechner.net'
Tell acme to renew the certificate (I have problem make a forced renewal for ec-256 cert, I had to recreate it):
su -l acme -c "cd /var/db/acme && acme.sh --renew --force -k ec-256 -d vmail2.fechner.net"
su -l acme -c "cd /var/db/acme && acme.sh --renew --force -k 2048 -d vmail2.fechner.net"
Feb 03 | Letsencrypt | 3 min read |
Oct 04 | HAProxy | 3 min read |
Oct 03 | Poudriere | 9 min read |
Jul 05 | Install FreeBSD | 2 min read |
Apr 29 | ZFS | 35 min read |