如何安装SSL证书

0
5349

提前了解的内容:

  • key
  • csr
  • CA (certificate authorities)
  • CA certification
  • intermediate CA
  • .pfx .crx

安装所需文件

Apache2

  • .key
  • .crt
  • .ca-bundle (cat *CA.crt > domain.ca-bundle)

IIS

  • .pfx
  • *CA.crt

证书格式转化

from .crt to .pfx

# 会让输密码,为了防止忘记,就直接回车好了

openssl pkcs12 -export -out domain.pfx -inkey domain.key -in domain.crt

ca-bundle文件生成

Linux命令

# 一般CA证书的命名为*CA.crt

cat *CA.crt > domain.ca-bundle

或者

# 把所有CA证书放到下面的命令中

cat firstCA.crt secondCA.crt thirdCA.crt … > domain.ca-bundle

windows命令

# 同样把所有的CA证书放到下面的命令中

copy firstCA.crt + secondCA.crt + … + lastCA.crt domain.ca-bundle

Apache 2.4安装

  1. 先把证书放在/etc/apache2/ssl目录下(路径可以改,比如/etc/httpd/ssl)
  2. 修改apache2的配置
  3. 重启apache2

<IfModule mod_ssl.c>

  <VirtualHost _default_:443>

    ServerAdmin admin@localhost  

    ServerName  domain.com

    DocumentRoot /var/www/html

 

    <Directory “/var/www/html”>

      Options -Indexes

      AllowOverride All

      Require all granted

    </Directory>

 

    SSLEngine on

    SSLCertificateKeyFile   /etc/apache2/ssl/domain.key

    SSLCertificateFile      /etc/apache2/ssl/domain.crt

    SSLCertificateChainFile /etc/apache2/ssl/domain.ca-bundle

  </VirtualHost>

</IfModule>

IIS安装

双击安装CA证书,选择自动选择目录安装,或者指定安装到中间根证书列表中

制作好pfx格式的证书后在IIS里面安装pfx格式的证书

在选定网站的网站下绑定443端口,选择正确的外网ip(也就是域名解析的ip),并配置好合适的主机名(就是域名),重启IIS