apachehttp服务器上的SSL

apachehttp服务器上的SSL,apache,ssl,apache2,ssl-certificate,private-key,Apache,Ssl,Apache2,Ssl Certificate,Private Key,我有两个Apache服务器的crt文件: 1\u root\u bundle.crt 2_my_domain_name.com.crt 和其他捆绑包: 1_Intermediate.crt 2_my_domain_name.com.crt root.crt 我改了 /etc/apache2/sites-available/default-ssl.conf 并尝试了上述文件的各种组合,但在Apache2服务重新启动SSL不起作用后,浏览器显示“连接不安全”: 如何在Apache服务器上

我有两个Apache服务器的crt文件:

  • 1\u root\u bundle.crt
  • 2_my_domain_name.com.crt
和其他捆绑包:

  • 1_Intermediate.crt
  • 2_my_domain_name.com.crt
  • root.crt
我改了

/etc/apache2/sites-available/default-ssl.conf 
并尝试了上述文件的各种组合,但在Apache2服务重新启动SSL不起作用后,浏览器显示“连接不安全”:


如何在Apache服务器上创建SSL

缺少带有证书私钥的密钥文件。通常它有
.key
扩展名,如
2\u my\u domain\u name.com.key
,文件内容以
----BEGIN PRIVATE key------

您的配置应该如下所示

SSLEngine on
SSLCertificateFile      /etc/apache2/ssl/2_my_domain_name.com.crt
SSLCertificateKeyFile   /etc/apache2/ssl/2_my_domain_name.com.key
SSLCertificateChainFile /etc/apache2/ssl/1_root_bundle.crt
SSLCertificateChainFile指向一个多功能文件,您可以在其中组装证书颁发机构(CA)的证书,CA构成服务器证书的证书链

因此,请确保
1\u root\u bundle.crt
包含
1\u Intermediate.crt
内容,并且是PEM格式(base64带有
--开始证书-----结束证书---
头)

如果使用apache>=2.4.8,还可以连接指向
SSLCertificateFile

SSLCertificateChainFile在版本2.4.8中变得过时,因为SSLCertificateFile被扩展为也从服务器证书文件加载中间CA证书


缺少带有证书私钥的密钥文件。通常它有
.key
扩展名,如
2\u my\u domain\u name.com.key
,文件内容以
----BEGIN PRIVATE key------

您的配置应该如下所示

SSLEngine on
SSLCertificateFile      /etc/apache2/ssl/2_my_domain_name.com.crt
SSLCertificateKeyFile   /etc/apache2/ssl/2_my_domain_name.com.key
SSLCertificateChainFile /etc/apache2/ssl/1_root_bundle.crt
SSLCertificateChainFile指向一个多功能文件,您可以在其中组装证书颁发机构(CA)的证书,CA构成服务器证书的证书链

因此,请确保
1\u root\u bundle.crt
包含
1\u Intermediate.crt
内容,并且是PEM格式(base64带有
--开始证书-----结束证书---
头)

如果使用apache>=2.4.8,还可以连接指向
SSLCertificateFile

SSLCertificateChainFile在版本2.4.8中变得过时,因为SSLCertificateFile被扩展为也从服务器证书文件加载中间CA证书

1) 安装Apache HTTP服务器,mod_ssl

2) 配置httpd

请记住禁用SSLv2和SSLv3,因为它们易受攻击

  # Toggle on the SSL/TLS Protocol Engine
  SSLEngine On
  # The signed certificate of the server
  SSLCertificateFile /etc/pki/tls/myserver/myserver.crt
  # The private key of the server
  SSLCertificateKeyFile /etc/pki/tls/myserver/myserver.key
  # The intermediate_certificate of the server
  SSLCertificateChainFile /etc/pki/tls/myserver/tls-ca-chain.pem

  # Accept only strong encryption
  SSLProtocol             all -SSLv2 -SSLv3
  SSLCipherSuite           HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK
  SSLHonorCipherOrder     on
3) 检查证书文件的权限

UPD: 如何一步创建密钥和证书签名请求:

openssl req -new -newkey rsa:2048 -nodes -keyout myserver.key -out myserver.csr
接下来,您必须将此csr文件发送到其中一个证书颁发机构。他们将发回您的签名证书和中间证书

您还可以创建自签名证书

1)安装Apache HTTP服务器,mod_ssl

2) 配置httpd

请记住禁用SSLv2和SSLv3,因为它们易受攻击

  # Toggle on the SSL/TLS Protocol Engine
  SSLEngine On
  # The signed certificate of the server
  SSLCertificateFile /etc/pki/tls/myserver/myserver.crt
  # The private key of the server
  SSLCertificateKeyFile /etc/pki/tls/myserver/myserver.key
  # The intermediate_certificate of the server
  SSLCertificateChainFile /etc/pki/tls/myserver/tls-ca-chain.pem

  # Accept only strong encryption
  SSLProtocol             all -SSLv2 -SSLv3
  SSLCipherSuite           HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK
  SSLHonorCipherOrder     on
3) 检查证书文件的权限

UPD: 如何一步创建密钥和证书签名请求:

openssl req -new -newkey rsa:2048 -nodes -keyout myserver.key -out myserver.csr
接下来,您必须将此csr文件发送到其中一个证书颁发机构。他们将发回您的签名证书和中间证书


您还可以创建自签名证书

您可以将捆绑文件与SSLCertificateChainFile一起使用

SSLCertificateFile /home/ubuntu/tad.com/tad.com.crt
SSLCertificateKeyFile /home/ubuntu/tad.com/tad.com.key
SSLCertificateChainFile /home/ubuntu/tad.com/intermediate_bundle.crt
SSLCACertificateFile /home/ubuntu/zup.today/intermediate_bundle.crt

如果您使用的是bundle,那么它将在没有SSLCertificateChainFile文件的情况下工作

SSLCertificateFile /home/ubuntu/tad.com/tad.com.crt
SSLCertificateKeyFile /home/ubuntu/tad.com/tad.com.key
SSLCACertificateFile /home/ubuntu/zup.today/intermediate_bundle.crt

您可以将捆绑文件与SSLCertificateChainFile一起使用

SSLCertificateFile /home/ubuntu/tad.com/tad.com.crt
SSLCertificateKeyFile /home/ubuntu/tad.com/tad.com.key
SSLCertificateChainFile /home/ubuntu/tad.com/intermediate_bundle.crt
SSLCACertificateFile /home/ubuntu/zup.today/intermediate_bundle.crt

如果您使用的是bundle,那么它将在没有SSLCertificateChainFile文件的情况下工作

SSLCertificateFile /home/ubuntu/tad.com/tad.com.crt
SSLCertificateKeyFile /home/ubuntu/tad.com/tad.com.key
SSLCACertificateFile /home/ubuntu/zup.today/intermediate_bundle.crt

如何获取.key文件?您是(应该)创建私钥的人。您可以使用openssl生成它。然后可以从密钥创建csr(证书签名请求)文件。您必须将该文件发送给证书颁发机构,他们将发回与您的密钥匹配的签名证书以及中间证书。如何获取.key文件?您是(应该)创建私钥的人。您可以使用openssl生成它。然后可以从密钥创建csr(证书签名请求)文件。您必须将其发送到证书颁发机构,他们将发回与您的密钥匹配的签名证书和中间证书。