将密钥/证书移至另一台机器后,Apache 中的 SSL 配置失败

将密钥/证书移至另一台机器后,Apache 中的 SSL 配置失败

我正在将我的网站移动到另一台服务器,在移动 SSL 密钥和证书并重新创建相同的 Apache 配置后,我在 Apache 服务重新启动(域匿名)时在错误日志中遇到以下内容:

[Sun May 24 22:21:05.579373 2015] [ssl:emerg] [pid 9777] AH02561: Failed to configure certificate 127.0.0.1:443:0, check /etc/ssl/certs/example.com.crt
[Sun May 24 22:21:05.579407 2015] [ssl:emerg] [pid 9777] SSL Library Error: error:140AD009:SSL routines:SSL_CTX_use_certificate_file:PEM lib
AH00016: Configuration Failed

它还阻止对 :80 和 :443 的访问。我已验证文件位于正确的位置,并且所有内容(至少 SSL)都已配置为与旧服务器上相同。我在这里遗漏了什么?

以下是 sites-available/default-ssl.conf(域名匿名)的片段:

SSLCertificateFile /etc/ssl/certs/example.com.crt
SSLCertificateKeyFile /etc/ssl/private/example.com.key
SSLCertificateChainFile /etc/ssl/certs/bundle.crt

新服务器规格:Debian 8(旧版本为 Debian 7)、原始 Apache 2.4.10。

更多潜在线索:

# openssl x509 -noout -modulus -in /etc/ssl/certs/example.com.crt | openssl md5
unable to load certificate
(stdin)= d41d8cd98f00b204e9800998ecf8427e
# openssl x509 -noout -modulus -in /etc/ssl/private/example.com.key | openssl md5
unable to load certificate
140331629921936:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:703:Expecting: TRUSTED CERTIFICATE
(stdin)= d41d8cd98f00b204e9800998ecf8427e
# file /etc/ssl/private/example.com.key
/etc/ssl/private/example.com.key: PEM RSA private key
# file /etc/ssl/certs/example.com.crt
/etc/ssl/certs/example.com.crt: PEM certificate

答案1

从 RHEL 6 主机转到 RHEL 8 主机时,我遇到了同样的问题。SSL 库中的某些内容肯定变得更加严格,结果我的证书文件有“DOS”格式的换行符。您可以使用“vi -b your.crt”查看它们,然后使用以下命令从 vi/vim 中删除它们:

:%s/<Ctrl-V><Ctrl-M//g

其中 或 以上实际上是按下相应的控制键组合。

不过我不确定这是否是问题所在,因为文件在“END CERTIFICATE”行之前还有一个空白行,我也在工作过程中删除了它。也许这就是问题所在。

相关内容