Обновите сертификат с помощью certbot, чтобы добавить поддомен - PullRequest
0 голосов
/ 21 апреля 2019

У меня есть домен с установленным сертификатом LetsEncrypt и настройкой Apache Conf для пересылки www в non-www и не в ssl в ssl.Все работало отлично, пока я не решил добавить поддомен и попытался сгенерировать новый сертификат для обоих типов.

Теперь я получаю следующий вывод при запуске certbot:

root@arthas:~# certbot
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator apache, Installer apache

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: domain.com
2: playground.domain.com
3: www.playground.domain.com
4: www.domain.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1,2,3,4

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
You have an existing certificate that contains a portion of the domains you
requested (ref: /etc/letsencrypt/renewal/domain.com.conf)

It contains these names: domain.com, www.domain.com

You requested these names for the new certificate: domain.com,
playground.domain.com, www.playground.domain.com, www.domain.com.

Do you want to expand and replace this existing certificate with the new
certificate?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(E)xpand/(C)ancel: e
Renewing an existing certificate
Performing the following challenges:
http-01 challenge for domain.com
http-01 challenge for playground.domain.com
http-01 challenge for www.domain.com
http-01 challenge for www.playground.domain.com
Waiting for verification...
Cleaning up challenges
Deploying Certificate to VirtualHost /etc/apache2/sites-enabled/000-default-le-ssl.conf
Created an SSL vhost at /etc/apache2/sites-enabled/000-default-le-ssl.conf
Deploying Certificate to VirtualHost /etc/apache2/sites-enabled/000-default-le-ssl.conf
Deploying Certificate to VirtualHost /etc/apache2/sites-enabled/000-default-le-ssl.conf
An unexpected error occurred:
ValueError: Unable to set value to path!
Please see the logfiles in /var/log/letsencrypt for more details.

IMPORTANT NOTES:
 - Unable to install the certificate
 - Congratulations! Your certificate and chain have been saved at /etc/letsencrypt/live/domain.com/fullchain.pem
   Your key file has been saved at: /etc/letsencrypt/live/domain.com/privkey.pem
   Your cert will expire on 2019-07-19.
   To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option.
   To non-interactively renew *all* of your certificates, run "certbot renew"
 - Some rewrite rules copied from /etc/apache2/sites-enabled/000-default.conf were disabled in the vhost for your HTTPS site located at /etc/apache2/sites-enabled/000-default-le-ssl.conf because they have the potential to create redirection loops.

Кроме того, я скопировал содержимое моего файла 000-default.conf ниже:

# Added to mitigate CVE-2017-8295 vulnerability
UseCanonicalName On

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        ServerName domain.com
        ServerAlias www.domain.com

        DocumentRoot /var/www/html

        <Directory /var/www/html/>
            Options FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        RewriteEngine on
        RewriteCond %{SERVER_NAME} =www.domain.com [OR]
        RewriteCond %{SERVER_NAME} =domain.com [OR]
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        ServerName playground.domain.com
        ServerAlias www.playground.domain.com

        DocumentRoot /var/www/html/playground

        <Directory /var/www/html/playground>
            Options FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        RewriteEngine on
        RewriteCond %{SERVER_NAME} =www.playground.domain.com [OR]
        RewriteCond %{SERVER_NAME} =playground.domain.com [OR]
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

1 Ответ

0 голосов
/ 08 мая 2019

Похоже, у вас есть несколько .conf файлов, которые могут вызывать конфликт.

  • Метод 1: поместить все правила VirtualHost *:80> и <VirtualHost *:443> в один и тот же файл конфигурации
  • Способ 2: держите их отдельно и добавьте Include /path/to/httpd-le-ssl.conf в конец 000-default.conf

Запустите $ sudo certbot renew --dry-run, чтобы проверить, успешно ли работает ваш пересмотренный конфиг.

Использование --dry-run не повлияет на ваши ограничения, поскольку вы устраняете неполадки и исправляете конфигурацию.После успешного завершения вы можете запустить команду renew снова без --dry-run

...