dnf install epel-release
dnf install certbot python3-certbot-nginx
/etc/letsencrypt/
# Просмотр сертификатов
# Список всех сертификатов, их доменов и сроков окончания
certbot certificates
# Отдельно посмотреть файл сертификата на окончание
openssl x509 -enddate -noout -in /etc/letsencrypt/live/autodiscover.gabelstapler-gebraucht.at/cert.pem
# Отдельно подключиться и проверить
openssl s_client -connect 192.168.1.20:25 -starttls smtp
openssl s_client -connect 192.168.1.20:587 -starttls smtp
openssl s_client -connect 192.168.1.20:465
# Дополнительно сразу срок видеть
openssl s_client -connect 192.168.1.20:25 -starttls smtp | openssl x509 -noout -dates
openssl s_client -connect 192.168.1.20:587 -starttls smtp | openssl x509 -noout -dates
openssl s_client -connect 192.168.1.20:465 | openssl x509 -noout -dates
# Какой сертификат использует postfix
postconf -n | grep tls_cert_file
# Сгенерировать сертификаты
certbot run --nginx
# Сгенерировать, предложит ввести email для напоминания о продлении сертификата и согласиться с лицензионным соглашением
certbot certonly --nginx -d task.symfio.net
# Сгенерировать без ввода email'а
certbot certonly --nginx --register-unsafely-without-email -d task.symfio.net
# Сгенерировать без nginx, предложит выбрать 2 варианта
# 1: Spin up a temporary webserver (standalone)
# выбираем 1. Но нужно, чтобы firewall не блокировал 80 порт и также ничего не было запущено на 80 порте (netstat -tunlp)
certbot certonly --register-unsafely-without-email -d mail.nsm.hk.com
# Перегенерировать (выпустить новые) сертификаты
certbot --nginx certonly --force-renew -d task.symfio.net
# Настроить автоматическое продление
systemctl enable --now certbot-renew.timer
# Просмотреть таймеры systemd, он должен быть в списке
systemctl list-timers
# Проверить работу автоматического продления сертификатов (получает и перезапускает nginx)
systemctl status certbot-renew.timer
# Если не включен сервис
systemctl enable --now certbot-renew.timer
# Проверить работу в логах
less /var/log/letsencrypt/letsencrypt.log
# Или если архивы ушли, то
mc
# открываем нужную дату (включает все до нее с последнего архива) .gz – просто открываем в mc, закрываем и смотрим вывод, должно быть сообщение о продление (самое быстрое найти – там будут сами сертификаты с BEGIN до END.
# Cимулируем продление и проверяем работу службы продления сертификатов
certbot renew --dry-run
# Удалить сертификат по имени
certbot delete --cert-name mail.gabelstapler-gebraucht.at
Хуки нужны, когда нужны дополнительные действия Например, для harbor можно перезапустить nginx, иначе он не подхватывает обновленные сертификаты и остается со старыми /usr/bin/docker stop nginx /usr/bin/docker start nginx , но если нужен доступ по порту, то так не работает
nano /etc/letsencrypt/renewal-hooks/pre/harbor.sh
#!/bin/bash
cd /srv/harbor/ && docker-compose down
chmod 755 /etc/letsencrypt/renewal-hooks/pre/harbor.sh
nano /etc/letsencrypt/renewal-hooks/post/harbor.sh
#!/bin/bash
cd /srv/harbor && ./install.sh
chmod 755 /etc/letsencrypt/renewal-hooks/post/harbor.sh
Симулируем и проверяем, что оба действия выполняются - до и после генерации сертификатов
certbot renew --dry-run
Проверяем, уже не симулируя. Должно после обновления страницы поменять даты сертификаты на новые
certbot --nginx certonly --force-renew -d hub.symfio.net
❌
Saving debug log to /var/log/letsencrypt/letsencrypt.log
The nginx plugin is not working; there may be problems with your existing configuration.
The error was: NoInstallationError("Could not find a usable 'nginx' binary. Ensure nginx exists, the binary is executable, and your PATH is set correctly.")
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /var/log/letsencrypt/letsencrypt.log or re-run Certbot with -v for more details.
Решение: Запустить и указать, где, что лежит
certbot certonly --nginx --nginx-ctl /usr/local/openresty/nginx/sbin/nginx --nginx-server-root /usr/local/openresty/nginx/conf
❌
2023/08/03 08:22:36 [error] 13286#13286: *32 open() "/usr/share/nginx/html/.well-known/acme-challenge/asdasd" failed (2: No such file or directory), client: ipadress, server: ipadress, request: "GET /.well-known/acme-challenge/asdasd HTTP/1.1", host: "url"
Решение: Создать необходимые папки и указать (или проверить) в конфигах nginx'а куда ссылается location /.well-known – проверить root папка в конфиге (server {}).