Apache HTTP 服务器上的 SSL

SSL on Apache HTTP Server

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

和其他捆绑包:

我修改了

/etc/apache2/sites-available/default-ssl.conf 

并尝试了上述文件的各种组合,但在 Apache2 服务重启后 SSL 不起作用,浏览器显示 "Connection is not secure":

SSLEngine on
SSLCertificateFile      /etc/apache2/ssl/1_Intermediate.crt
SSLCertificateKeyFile   /etc/apache2/ssl/2_my_domain_name.com.crt
SSLCertificateChainFile /etc/apache2/ssl/root.crt

如何在 Apache 服务器上制作 SSL?

它缺少包含您的证书私钥的密钥文件。通常它具有 .key 扩展名,如 2_my_domain_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 指向一个 all-in-one 文件,您可以在其中 assemble 形成服务器证书证书链的证书颁发机构 (CA) 的证书。

所以确保1_root_bundle.crt包含1_Intermediate.crt内容并且是PEM格式(base64 with --- BEGIN CERTIFICATE --- ----END CERTIFICATE--- headers)

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

的文件中的所有证书

SSLCertificateChainFile became obsolete with version 2.4.8, when SSLCertificateFile was extended to also load intermediate CA certificates from the server certificate file.

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

如果您使用的是捆绑包,那么它可以在没有 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