我在用着https://www.sslshopper.com/ssl-checker.html检查我的网站,但出现以下错误消息:
None of the common names in the certificate match the name that was entered (example.net). You may receive an error when accessing this site in a web browser. It looks like you just need to add the "www." when accessing the site with SSL. Learn more about name mismatch errors.
我的000-default-le-ssl.conf
设置如下:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ServerName example.net
ServerAlias www.example.net
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
</IfModule>
Include /etc/letsencrypt/options-ssl-apache.conf
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.net
RewriteRule ^ https://www.%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
SSLCertificateFile /etc/letsencrypt/live/www.example.net-0001/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/www.example.net-0001/privkey.pem
</VirtualHost>
<VirtualHost *:80>
ServerName example.net
ServerAlias www.example.net
Redirect permanent / https://www.example.net/
</VirtualHost>
</IfModule>
<IfModule mod_ssl.c>
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
</IfModule>
</VirtualHost>
是不是因为我只有SSLCertificateFile
swww.example.net
而缺少example.net
?如果是这样的话,我尝试强制重定向到 来www.example.net
解决这个问题。
(更新:下面已解决)
答案1
解决了:我尝试重新安装 lets encrypt via sudo certbot --apache
,然后当被问到时,Which names would you like to activate HTTPS for?
我选择了两个选项(我过去1. example.net 2. www.example.net
必须只选择了该选项。)www