apache - mod24_ssl 不会读取针对 openssl 验证的证书

标签 apache ssl amazon-ec2

所以我在尝试在 EC2 服务器上启动 apache 时遇到了问题。

规范:

OS: Amazon Linux AMI r2016.03
httpd24.x86_  64 2.4.18-1.64.amzn1
mod24_ssl.x86_64 2.4.18-1.64.amzn1

Apache 配置:

<VirtualHost *:443>
    DocumentRoot            /var/www/zxurian.com/html/
    ServerAdmin             root@localhost.com
    ServerName              zxurian.com

    DirectoryIndex          index.php

    SSLEngine               on
    SSLProtocol             all -SSLv2 -SSLv3 -TLSv1
    SSLCipherSuite          "AES256+EECDH:AES256+EDH"
    SSLHonorCipherOrder     on
    SSLCertificateFile      /etc/httpd/ssl/certificate.crt
    SSLCertificateChainFile /etc/httpd/ssl/certificate.cc-bundle
    SSLCertificateKeyFile   /etc/httpd/ssl/certificate.key

    Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
    Header always append X-Frame-Options SAMEORIGIN

    <Directory "/var/www/zxurian.com">
            Require all granted
            AllowOverride All
    </Directory>
    <FilesMatch "^\.">
            Order Allow,Deny
            Deny from All
    </FilesMatch>
    <DirectoryMatch "^\.|\/\.">
            Order Deny,Allow
            Deny from All
    </DirectoryMatch>
</VirtualHost>

我将私钥和购买的证书复制到服务器上使用。运行 openssl x509 -noout -text -in certificate.crt 显示证书信息。运行 openssl rsa -in certificate.key -check 给我一个 RSA key ok。但是,当尝试启动 apache 时,出现以下错误:

[Tue May 17 21:07:12.592129 2016] [ssl:emerg] [pid 8896] AH02572: Failed to configure at least one certificate and key for hub.tantor.com:443
[Tue May 17 21:07:12.592145 2016] [ssl:emerg] [pid 8896] SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: DH PARAMETERS) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?
[Tue May 17 21:07:12.592151 2016] [ssl:emerg] [pid 8896] SSL Library Error: error:0906D06C:PEM routines:PEM_read_bio:no start line (Expecting: EC PARAMETERS) -- Bad file contents or format - or even just a forgotten SSLCertificateKeyFile?
[Tue May 17 21:07:12.592158 2016] [ssl:emerg] [pid 8896] SSL Library Error: error:140A80B1:SSL routines:SSL_CTX_check_private_key:no certificate assigned

在这一点上,我没有想法。我已经验证该文件没有额外的行结尾。文件上的 vi -b 显示文件中没有额外信息(即没有 ^M 或 windows 行结尾)。它的设置与我其他运行良好的 EC2 服务器相同。

任何人还有什么我可以检查的吗?

根据请求添加:

[zxurian@ip-10-0-200-22 ssl]$ egrep 'BEGIN|END' certificate.crt
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
[zxurian@ip-10-0-200-22 ssl]$ egrep 'BEGIN|END' certificate.key
-----BEGIN PRIVATE KEY-----
-----END PRIVATE KEY-----

最佳答案

首先是线索:您不能再依赖于您的 VirtualHost 定义了。您必须像这样从 conf.d/ssl.conf 引用有效的证书/ key 对(位置适用于我的 Fedora 系统):

SSLCertificateFile /etc/pki/tls/certs/localhost.crt

SSLCertificateKeyFile /etc/pki/tls/private/localhost.pem

我的是自签名证书,从 httpd-2.2/openssl-1.0.2h 继承而来。证书采用 ascii PEM 格式。 key 已转换为 RSA 明文副本,因此 httpd 启动时不需要密码。 (在你这样做之前仔细评估你的环境)。为它制作什么证书似乎并不重要,因为它仍然是将呈现给客户端的 VirtualHost 部分中定义的证书。对我而言,这些证书(从 httpd-2.2 继承而来)采用 PEM 缩写形式,而相应的 key 同样采用 RSA 明文形式。当然,您必须加载 mod_ssl.so,但如果您有在 httpd-2.2 中工作的东西,那么您已经这样做了。郑重声明:我的系统上没有任何 dhparams.pem 文件(在我的案例中只是另一个错误线索)。

关于apache - mod24_ssl 不会读取针对 openssl 验证的证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37286747/

相关文章:

node.js - 如何在 Openshift NodeJS 应用程序上提供静态资源

reactjs Route Not Found 请求的 URL

php - 多个 mod_rewrite 规则

security - SSL:为什么 Chrome 会报告混合内容? (德鲁帕尔 6)

amazon-web-services - AWS 网络负载均衡器问题

node.js - 将所有请求通过管道传输到特定端口 - Node js 应用程序

c# - Window Phone 8 中的客户端证书

c - 根CA的SSL_CTX_set_verify()回调和深度

amazon-web-services - Ansible + AWS EC2 插件 + 用户名 + 动态 list 文件上的 ssh key

json - 是否可以从用户处获取 "instancecount"并使用云形成模板相应地创建 ec2 实例?