```{index} openssl ``` # Полезные команды ## Запрос на сертификат (CSR) ```bash openssl req \ -nodes \ -newkey rsa:2048 \ -keyout private.key \ -out example.com.csr \ -subj "/C=RU/ST=Moscow/L=Moscow/O=PHP-Development/OU=IT Department/CN=example.com" ``` ``````{tip} То же одной строкой: ```bash openssl req -nodes -newkey rsa:2048 -keyout private.key -out example.com.csr -subj "/C=RU/ST=Moscow/L=Moscow/O=PHP-Development/OU=IT Department/CN=example.com" ``` `````` --- ## Генерация самоподписного сертификата ### Команда OpenSSL ```bash openssl req \ -x509 \ -newkey rsa:2048 \ -sha256 \ -days 3650 \ -nodes \ -keyout /srv/registry/cert/registry.key \ -out /srv/registry/cert/registry.crt \ -addext 'subjectAltName = DNS:www.example.com' \ -subj "/C=RU/ST=Msk/L=Msk/O=PHP-Development/OU=IT/CN=example.com" ``` ``````{tip} То же одной строкой: ```bash openssl req -x509 -newkey rsa:2048 -sha256 -days 3650 -nodes -keyout /srv/registry/cert/registry.key -out /srv/registry/cert/registry.crt -addext 'subjectAltName = DNS:www.example.com' -subj "/C=RU/ST=Msk/L=Msk/O=PHP-Development/OU=IT/CN=example.com" ``` `````` (generate_new_cert_script)= ### Скрипт для ПРОДа На хосте `c04-ansible` от имени пользователя `rundeckadm`: 1. ```bash cd ~/ansible/roles/nginx_update_certs_BETA/files/prod/ ``` 2. ```bash vim generate_new_cert.sh ``` 3. Меняем fqdn сайта: `site_fqdn='hse.appworks.ru'` 4. Сохраняем файл и выполняем скрипт. 5. Дальше распространяем новый сертификат пао фронтам с помощью плейбука ansible: {doc}`/ansible/playbooks/nginx-update-certs` --- ```{index} openssl; s_client ``` ## Получение сертификата с помощью openssl s_client ```bash openssl s_client \ -showcerts \ -connect имя_внешнего_хоста:порт \ /dev/null \ | openssl x509 \ -outform PEM > 3rd_party_ssl_cert.pem ``` ``````{tip} То же одной строкой: ```bash openssl s_client -showcerts -connect имя_внешнего_хоста:порт /dev/null | openssl x509 -outform PEM > 3rd_party_ssl_cert.pem ``` `````` --- ```{index} freeipa; dogtag ``` ## Выпуск сертификата через FreeIPA ```bash ipa-getcert request -r \ -f /root/c04-git.sitefactory.local.crt \ -k /root/c04-git.sitefactory.local.key \ -N CN=c04-git.sitefactory.local \ -D c04-git.sitefactory.local \ -K HTTP/c04-git.sitefactory.local ``` ```{seealso} [Creating certs and keys for services using FreeIPA (Dogtag)](https://blog.christophersmart.com/2014/08/24/creating-certs-and-keys-for-services-using-freeipa-dogtag/) ```