Certbot — open-source утилита для выпуска бесплатных SSL-сертификатов Let`s Encrypt. Основным спонсором первой и одним из спонсоров второй является некоомерческий фонд Electronic Frontier Foundation. Но это всё прелюдия, давайте уже к делу.
Устанавливаем certbot:
apt install certbot
Я рассмотрю разовый ручной выпуск, без привязки к автообновлению сертификата и интеграции с вебсервером.
Важный нюанс — выпуск сертификата должен производиться на той машине, для которой выпускается, т.к. в процессе выпуска сертификационный центр проверит соответствие между dns-записью и машиной, на которой отрабатывает certbot.
Выпускаем сертификат:
certbot certonly -d yourhost.net -d www.yourhost.netКак видно из команды, можно добавить в сертификат несколько доменов, вставив ключ -d перед каждым из них . В процессе будет задано несколько вопросов — они и ответы на них выделены жирным.
Saving debug log to /var/log/letsencrypt/letsencrypt.log
How would you like to authenticate with the ACME CA?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Spin up a temporary webserver (standalone)
2: Place files in webroot directory (webroot)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Requesting a certificate for yourhost.net and www.www.yourhost.net
Input the webroot for yourhost.net: (Enter 'c' to cancel): /var/www/yourhost.net
Select the webroot for www.yourhost.net:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Enter a new webroot
2: /var/www/yourhost.net
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Successfully received certificate.
Certificate is saved at: /etc/letsencrypt/live/yourhost.net/fullchain.pem
Key is saved at: /etc/letsencrypt/live/yourhost.net/privkey.pem
This certificate expires on 2023-07-19.
These files will be updated when the certificate renews.
Certbot has set up a scheduled task to automatically renew this certificate in the background.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you like Certbot, please consider supporting our work by:
* Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
* Donating to EFF: https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
После успешного выпуска SSL-сертификата и приватного ключа certbot положит их в директорию, сообщит полные пути к ним и дату окончания действия (в листинге выше — подчеркнуто). Сертификаты выпускаются на 3 месяца.
Теперь нам останется только положить их в место, где их будет искать вебсервер (если это место ему указано, конечно):
cp /etc/letsencrypt/live/yourhost.net/fullchain.pem /etc/ssl/yourhost.crt
cp /etc/letsencrypt/live/yourhost.net/privkey.pem /etc/ssl/yourhost.key