服务器证书不包含与服务器名称匹配的 ID

服务器证书不包含与服务器名称匹配的 ID

我们的服务器昨天升级了,所以现在有了更新的 Ubuntu、Apache 2.4.10、PHP 等。在我把所有东西放回去后,Apache 开始抱怨我的配置。

该服务器托管一个站点,该站点使用通配符为不同的客户提供动态内容,并包含 3 个通配符证书以针对这些客户提供不同的服务。

带有通配符的配置部分如下所示:

<VirtualHost *:80>
    ServerName *.dashboard.example.com
    ServerAlias *.dashboard.example.com
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(.+)\.dashboard.example\.com$
    RewriteRule ^/(.*)$ https://%1.dashboard.example.com/$1 [R=302,L]
</VirtualHost>

<VirtualHost *:443>
    ServerAdmin [email protected]
    ServerName *.dashboard.example.com
    ServerAlias *.dashboard.example.com
    DocumentRoot /var/www/dashboard.example.com/web

    <Directory />
        AllowOverride All
        Options -Indexes +MultiViews +FollowSymLinks
        Order Deny,Allow
        Allow from all
    </Directory>

    ErrorLog /var/log/apache2/dashboard.example.com-error.log
    CustomLog /var/log/apache2/dashboard.example.com-access.log combined

    SSLEngine on
    SSLCertificateFile /etc/ssl/certs/bundle_wc_dashboard_example_com.crt
    SSLCertificateKeyFile /etc/ssl/certs/wildcard_dashboard_example_com.key
</VirtualHost>

请注意,我使用捆绑包作为证书文件。使用单独的文件作为中间文件和根文件会导致使用 SSL 检查时结果更糟。然后无法识别 GeoTrust 证书。我的 SSL 证书供应商解释说,从 Apache 2.4 开始,证书应该是捆绑包。

所以这对我来说不起作用:

SSLCertificateFile /etc/ssl/certs/wildcard_dashboard_example_com.crt
SSLCertificateKeyFile /etc/ssl/certs/wildcard_dashboard_example_com.key
SSLCertificateChainFile /etc/ssl/certs/GeoTrust_Global_CA.crt
SSLCertificateChainFile /etc/ssl/certs/RapidSSL_SHA256_CA_G3.crt

然而,上述操作在 Apache 2.2 上确实有效。

当我尝试启动 apache 时,它​​会抱怨该ServerName值:

[FAIL] Reloading web server: apache2 failed!
[warn] The apache2 configtest failed. Not doing anything. ... (warning).
Output of config test was:
AH00526: Syntax error on line 42 of /etc/apache2/sites-enabled/3-production.conf:
Invalid ServerName "*.dashboard.example.com" use ServerAlias to set multiple server names.
Action 'configtest' failed.
The Apache error log may have more information.

因此,似乎不允许使用星号。如果我删除星号,apache 会启动,但域的错误日志中会出现错误:

2016 年 3 月 11 日星期五 10:32:13.821304] [ssl:warn] [pid 18019] AH01909:dashboard.example.com:443:0 服务器证书不包含与服务器名称匹配的 ID

我从其他来源找到了以下命令,该命令应用于确定应用作 ServerName 的 CommonName:

openssl x509 -in wildcard_dashboard_example_com.crt -noout -subject

返回:

主题=/CN=*.dashboard.example.com

我的浏览器确实显示了一个绿色锁,但 SSL 检查抱怨我缺少中间/链证书文件(见屏幕截图)。同一台服务器上的其他 2 个通配符域和 1 个不是通配符的普通子域也出现了同样的问题。Apache 甚至声称server certificate does NOT include an ID which matches the server name。该网站使用通配符为不同客户提供动态内容,并包含 3 个用于这些客户的不同服务的通配符证书。

有什么办法可以修复这个问题吗?我还能做什么来检查哪里出了问题?

SSL 检查失败

2016 年 5 月 18 日更新

我在 4 月初修复了这个问题。看来提供 SSL 证书的公司给了我们一个旧的根证书。他们给我发了一个 zip 文件,其中包含一个捆绑证书和一个单独的证书文件。我尝试多次安装它们。然后我手动将所有文件的内容与其他可以正常工作的网站进行了比较。我注意到了差异,并从他们的网站手动重新下载了证书。

GeoTrust 证书则不同。安装后,一切都运行良好。我的老板告诉我他会就此事与他们联系,但不幸的是,这种情况从未发生过。无论如何,我很高兴它现在可以正常工作了。

答案1

如果证书仅对 有效*.dashboard.example.com,则对 无效dashboard.example.com(后者与通配符不匹配)。

ServerName用于指定网站的规范名称(一个名称)。
其他名称和通配符仅用于ServerAlias

设置例如ServerName foo.dashboard.example.com应该可以工作(结合ServerAlias您拥有的)。


关于证书链中提到的问题,这些问题似乎与实际问题无关。
我建议确保所有必需的中级证书已正确捆绑。

正如你所说SSLCertificateChainFile已经过时了,你不需要使用它,你可以把所有的证书放进去SSLCertificateFile

Qualy 的 SSL 实验室测试可用于查看是否缺少任何中间证书或是否存在其他问题。

相关内容