使用Certbot签发HTTPS证书

Ubuntu20.04

官方文档

Let’s Encrypt 是一个自动签发 https 证书的免费项目
Certbot 是 Let’s Encrypt 官方推荐的证书生成客户端工具

安装Certbot

apt install certbot

apt update
apt install software-properties-common
add-apt-repository ppa:certbot/certbot
apt update

签发证书

单域名

  • standalone 方式: certbot 会自己运行内置的web server 来进行验证。
  • webroot 方式: certbot 会利用既有的 web server,在其 web root目录下创建隐藏文件, Let’s Encrypt 服务端会通过域名来访问这些隐藏文件,以确认你的确拥有对应域名的控制权。
standalone

certbot 会运行内置web server 来进行验证。

certbot certonly --standalone -d www.domain.com
webroot

certbot 会利用既有的 web server,在其 web root目录下创建隐藏文件, Let’s Encrypt 服务端会通过域名来访问这些隐藏文件,以确认你的确拥有对应域名的控制权。

certbot certonly --webroot -w site_directory -d www.domain.com --agree-tos --email test@163.com

www.domain.com:域名
site_directory:网站目录,例nginx root配置

通配符域名

todo

证书文件说明

`privkey.pem`  : the private key for your certificate.
`fullchain.pem`: the certificate file used in most server software.
`chain.pem`    : used for OCSP stapling in Nginx >=1.3.7.
`cert.pem`     : will break many server configurations, and should not be used
                 without reading further documentation (see link below).

验证配置

设置Nginx(或其他)服务器的HTTPS配置后,浏览器中访问https://www.domain.com,确认是否成功。

# nginx.conf
server {
        listen 443 ssl;
        server_name .domain.com;
        # 证书文件
        ssl_certificate fullchain.pem;
        # 秘钥文件
        ssl_certificate_key privkey.pem;
        # 协议
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
 }

证书续订

在证书过期(90天)之前,可以通过运行以下命令来续订。

# 使用 --dry-run 选项表示测试,非真正执行更新
# --cert-name:指定证书
# --force-renewal:强制更新
# certbot renew --cert-name www.***.work --force-renewal
certbot renew
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值