【问题标题】:SSL on Apache HTTP ServerApache HTTP 服务器上的 SSL
【发布时间】:2016-06-21 08:56:00
【问题描述】:

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

  • 1_root_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 不起作用,浏览器显示“连接不安全”:

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?

【问题讨论】:

    标签: apache ssl apache2 ssl-certificate private-key


    【解决方案1】:

    缺少包含您的证书私钥的密钥文件。通常它具有.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 指向一个一体化文件,您可以在其中组装形成服务器证书的证书链的证书颁发机构 (CA) 的证书。

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

    如果您使用 apache >= 2.4.8,您还可以连接指向 SSLCertificateFile 的文件中的所有证书

    SSLCertificateChainFile 在 2.4.8 版中已过时,当时 SSLCertificateFile 被扩展为也从服务器证书文件加载中间 CA 证书。

    【讨论】:

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

    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 文件发送给其中一个证书颁发机构。他们将发回您的签名证书和中间证书。

    您还可以创建自签名证书。

    【讨论】:

      【解决方案3】:

      您可以将捆绑文件与 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
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-10-31
        • 2014-11-09
        • 2020-09-16
        • 2016-04-19
        • 1970-01-01
        • 1970-01-01
        • 2013-07-02
        相关资源
        最近更新 更多