所以我在尝试在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>
我复制了私钥&amp;购买的证书到服务器使用。运行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-----
答案 0 :(得分:1)
首先提示:您不能仅仅依赖于VirtualHost
定义了。您必须引用conf.d / ssl.conf中的有效证书/密钥对,如此(位置适用于我的Fedora系统):
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.pem
Mine是一个自签名证书,从httpd-2.2 / openssl-1.0.2h继承。证书采用ascii PEM格式。密钥已转换为RSA清除副本,因此httpd启动时不需要密码。 (在您这样做之前仔细评估您的环境)。似乎证书的制作并不重要,因为它仍然是VirtualHost部分中定义的证书,将呈现给客户。对我来说,这些证书(从httpd-2.2转发)是PEM简短形式,而相应的密钥,再次是RSA清晰复制形式。当然你必须加载mod_ssl.so,但是如果你在httpd-2.2中有工作,那么你已经这样做了。记录:我的系统上没有任何dhparams.pem文件(在我的情况下只是另一个假导致)。