更新
This commit is contained in:
1 parent
5cd551a08e
commit
40cde540d6
33 files changed
+547
-319
No files matched your search
@@ -1,9 +1,13 @@
|
||||
---
|
||||
title: https实践,Let's Encrypt 免费泛域名 SSL 证书申请
|
||||
tags: []
|
||||
id: '304'
|
||||
categories:
|
||||
- - 分享
|
||||
- 分享
|
||||
tags:
|
||||
- https
|
||||
- Let's Encrypt
|
||||
- SSL证书
|
||||
- 免费泛域名
|
||||
date: 2018-07-12 11:26:42
|
||||
---
|
||||
|
||||
@@ -15,7 +19,7 @@ date: 2018-07-12 11:26:42
|
||||
|
||||
部署 HTTPS 网站的时候需要证书,证书由 CA 机构签发,大部分传统 CA 机构签发证书是需要收费的,这不利于推动 HTTPS 协议的使用。
|
||||
|
||||
[Let’s Encrypt](https://letsencrypt.org/) 也是一个 CA 机构,但这个 CA 机构是免费的!也就是说签发证书不需要任何费用。
|
||||
[Let’s Encrypt](https://letsencrypt.org/) 也是一个 CA 机构,但这个 CA 机构是免费的! 也就是说签发证书不需要任何费用。
|
||||
|
||||
[Let’s Encrypt](https://letsencrypt.org/) 是国外一个公共的免费 SSL 项目,由 Linux 基金会托管。由 Mozilla、思科、Akamai、IdenTrust 和 EFF 等组织发起,目的就是向网站自动签发和管理免费证书。以便加速互联网由 HTTP 过渡到 HTTPS,目前 Facebook 等大公司开始加入赞助行列。
|
||||
|
||||
@@ -35,13 +39,15 @@ ACME v2 是 ACME 协议的更新版本,泛域名证书只能通过 ACME v2 获
|
||||
|
||||
如果没有下载安装过Certbot,先下载Certbot客户端
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
wget https://dl.eff.org/certbot-auto
|
||||
```
|
||||
|
||||
然后把certbot-auto设为可执行权限
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
chmod a+x certbot-auto
|
||||
```
|
||||
|
||||
@@ -49,7 +55,8 @@ chmod a+x certbot-auto
|
||||
|
||||
如果已经安装了Certbot,查看下自己的Certbot客户端是不是支持 ACME v2 版本,官方介绍 Certbot 0.22.0 版本支持新的协议版本
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
./certbot-auto --version
|
||||
Upgrading certbot-auto 0.21.1 to 0.25.1...
|
||||
Replacing certbot-auto...
|
||||
@@ -70,7 +77,8 @@ certbot 0.22.0
|
||||
|
||||
使用 Certbot 客户端申请证书方法比较的简单,输入以下命令:
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
./certbot-auto certonly -d domain.com -d *.domain.com --manual --preferred-challenges dns --server https://acme-v02.api.letsencrypt.org/directory
|
||||
```
|
||||
|
||||
@@ -88,7 +96,8 @@ _2、\*.domain.com可作用于所有子域名,但好像不能作用于domain.c
|
||||
|
||||
执行完这一步之后,就是命令行的输出,请根据提示输入相应内容:
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
Saving debug log to /var/log/letsencrypt/letsencrypt.log
|
||||
Plugins selected: Authenticator manual, Installer None
|
||||
Cert is due for renewal, auto-renewing...
|
||||
@@ -116,7 +125,8 @@ Are you OK with your IP being logged?
|
||||
|
||||
继续查看命令行的输出,非常关键:
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Please deploy a DNS TXT record under the name
|
||||
_acme-challenge.xxxxx.com with the following value:
|
||||
@@ -130,7 +140,7 @@ Press Enter to Continue
|
||||
|
||||
执行到上图最后一步时,先暂时不要回车。要求配置 DNS TXT 记录,从而校验域名所有权,也就是判断证书申请者是否有域名的所有权。接下来需要按照提示在域名后台添加对应的 DNS TXT 记录。
|
||||
|
||||
上面输出要求给 \_acme-challenge.XXXXX.com 配置一条 TXT 记录,在没有确认 TXT 记录生效之前不要回车执行。
|
||||
上面输出要求给 \_acme-challenge. XXXXX.com 配置一条 TXT 记录,在没有确认 TXT 记录生效之前不要回车执行。
|
||||
|
||||
我使用的是阿里云的域名服务器,登录控制台操作如下图:
|
||||
|
||||
@@ -138,7 +148,8 @@ Press Enter to Continue
|
||||
|
||||
如上图所示,有两条DNS TXT,因为我们申请的时候就有两个域名,domain.com 和 \*.domain.com,所以我们在阿里云的后台添加一条DNS TXT后,我们回到命令行,按回车继续,然后会输出第二条DNS TXT
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Please deploy a DNS TXT record under the name
|
||||
_acme-challenge.xxxxx.com with the following value:
|
||||
@@ -152,7 +163,8 @@ Press Enter to Continue
|
||||
|
||||
同样,按照上面的步骤在阿里云的后台多加一条DNS TXT解析就好。加完稍等几分钟后,回到命令行,按回车
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
Waiting for verification...
|
||||
Cleaning up challenges
|
||||
|
||||
@@ -176,7 +188,8 @@ Press Enter to Continue
|
||||
|
||||
你也可以输入以下命令确认 TXT 记录是否生效:
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
dig -t txt _acme-challenge.XXXXXX.com @8.8.8.8
|
||||
|
||||
; <<>> DiG 9.10.6 <<>> -t txt _acme-challenge.XXXXXX.com @8.8.8.8
|
||||
@@ -202,7 +215,8 @@ _acme-challenge.dengtongyu.com.599 INTXT"XQOqY8npyso******ovtudA3zMd_C1dh9bjMEkb
|
||||
|
||||
到了这一步后,恭喜您,证书申请成功。 证书和密钥保存在下列目录:
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
/etc/letsencrypt/live/xxx.com/
|
||||
|
||||
├── cert.pem
|
||||
@@ -213,7 +227,8 @@ _acme-challenge.dengtongyu.com.599 INTXT"XQOqY8npyso******ovtudA3zMd_C1dh9bjMEkb
|
||||
|
||||
然后校验证书信息,输入如下命令:
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
openssl x509 -in /etc/letsencrypt/live/xxx.com/cert.pem -noout -text
|
||||
...
|
||||
Authority Information Access:
|
||||
@@ -231,7 +246,8 @@ X509v3 Subject Alternative Name:
|
||||
|
||||
Nginx 配置文件片断:
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
server {
|
||||
server_name xxx.com;
|
||||
listen 443 http2 ssl;
|
||||
@@ -243,4 +259,4 @@ server {
|
||||
proxy_pass http://127.0.0.1:8080;
|
||||
}
|
||||
}
|
||||
```
|
||||
```
|
||||
Reference in new issue
Block a user