記一次申請SSL證書流程

目的

申請域名證書 (DV SSL)

1. 使用acme 自動簽發(fā)

1.1 下載acme腳本(可以不用這一步)

git clone https://github.com/acmesh-official/acme.sh

1.2 安裝zcem

curl https://get.acme.sh | sh

1.3 運行腳本自動簽發(fā)

~/.acme.sh/acme.sh --issue -d 域名 --webroot web目錄

簽發(fā)成功如下

image.png

注:使用acme命令之前需要先注冊帳務(wù)使用命令即可,填入自己的郵箱

https://github.com/acmesh-official/acme.sh/wiki/ZeroSSL.com-CA
image.png

1.4 簽發(fā)成功后修改域名證書的存放位置
默認(rèn)簽發(fā)成功后的位置如:


image.png

使用以下命令修改存放位置以供使用

~/.acme.sh/acme.sh --install-cert -d 域名 \
--key-file       密鑰存放目錄  \
--fullchain-file 證書存放路徑 

2. 配置

2.1 Apache 配置

2.2.1. 編輯網(wǎng)站配置文件,例如 /etc/apache2/sites-enabled/xxx.conf ,添加443端口和相關(guān)配置:

<VirtualHost *:443>
    ServerName tlanyan.pp.ua
    # 日志等其他配置

    # ssl配置
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/tlanyan.pp.ua/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/tlanyan.pp.ua/privkey.pem
</VirtualHost>

注:如果apache第一次使用ssl,需要開啟 ssl mod,使用命令

a2enmod ssl

否則會報錯:


image.png

2.2.2 重啟apache服務(wù)

systemctl restart apache2.service

3. 查詢ssl證書有效期

使用以下命令

# 2、查看到期時間
openssl x509 -in xxx.crt -noout -dates

Attention:

  1. When add ssl using acme first, you must make sure your server can be reached from port 80
    So, first you should set ngxin running and turn default port on
  2. You should set webroot using --webroot or -w
  3. Whenever, You CAN reference its opensource repo https://github.com/acmesh-official/acme.sh
  4. Anyway if failed, try add --server letsencrypt https://stackoverflow.org.cn/questions/68447907

參考

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容