找到了一款永久免费的https证书并自动续期的产品certbot-auto以及免费https服务certbot-auto的使用注意事项

一、找到了一款永久免费的https证书并自动续期的产品certbot-auto

    之前写过一篇文章 Nginx配置免费自签名https证书、Nginx负载转发中的X-Forwarded-Proto意义及Access-Control-Allow-Origin同时允许http和https的跨域请求_nginx x-forwarded-proto-CSDN博客,实现了免费的https证书,但是那只是一个自验证的https证书,在浏览器里会被提示安全性有问题,网上各种云服务器上有很多https服务,但那些都是要花钱的,而且价格不菲,一年上千的都很多,不便宜啊。今天找到一个免费的https证书产品,自己试了一下,真的可以用,而且完全免费 publish:July 19, 2018 -Thursday。
    Let s Encrypt:如果要启用HTTPS,我们就需要从证书授权机构处获取一个证书,Let s Encrypt是一个证书授权机构。我们可以从 Let s Encrypt 获得网站域名的免费的证书。
    certbot-auto certbot-auto是Let s Encrypt推出的获取证书的客户端,可以让我们免费快速地获取Let s Encrypt证书。
    产品官网地址:https://certbot.eff.org/lets-encrypt/centos6-nginx

        首先自己选择自己的服务器(nginx/apache等)和系统(centos/ubuntu等).下载对应系统服务器的客户端.

#下载客户端并增加可执行文件权限, certonly可以不加,不加的话就表示让客户端直接帮你修改nginx配置文件,加了就只生成证书自己再手动配置nginx.

[root@iZ282iltjiwZ https]wget https://dl.eff.org/certbot-auto
[root@iZ282iltjiwZ https]chmod a+x certbot-auto
[root@iZ282iltjiwZ https]# ./certbot-auto --nginx certonly
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Error while running nginx -c /etc/nginx/nginx.conf -t.
nginx: [emerg] open() "/etc/nginx/nginx.conf" failed (2: No such file or directory)

 #上面的报错表示certbot-auto默认认为配置文件在/etc/nginx/nginx.conf路径,所以操作失败。因为certbot-auto会自动找到你服务里的所有域名,并按你需求对指定域名生成证书文件。这里就需要通过一个参数指定nginx.conf的路径。

[root@iZ282iltjiwZ https]# ./certbot-auto --nginx --nginx-server-root=/usr/local/nginx/conf certonly         
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator nginx, Installer nginx
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): 这里输入你的邮箱

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: 007.cn
2: www.007.cn
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter 'c' to cancel): 1,16,9
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for 007.cn
http-01 challenge for www.007.cn
Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/privkey.pem
   Your cert will expire on 2018-10-16. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot-auto
   again. To non-interactively renew *all* of your certificates, run
   "certbot-auto renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

如上命令如下,只需简单几个步骤就给服务器生成了证书文件,文件及意义如下:

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配置文件:添加443端口支持,并添加以下配置到server中。重启即可:

ssl on;
ssl_certificate /path/fullchain.pem;    #修改为上面fullchain.pem所在的路径
ssl_certificate_key /path/privkey.pem;  #修改为上面privkey.pem所在的路径
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;

二、免费https服务certbot-auto的使用注意事项

         publish:July 26, 2018 -Thursday 之前使用certbot-auto注册过多个域名,但在使用中也碰到了一些问题,第一是同一个域名注册有限制,因为第一次使用,重复进行了多次activate HTTPS,导致后来再使用时碰到如下提示:即超过了次数限制。

Waiting for verification...
Cleaning up challenges
An unexpected error occurred:
There were too many requests of a given type :: Error finalizing order :: too many certificates already issued for exact set of domains: 04007.cn: see https://letsencrypt.org/docs/rate-limits/
Please see the logfiles in /var/log/letsencrypt for more details.

        查看详细的使用限制文档:https://letsencrypt.org/docs/rate-limits/ 有提示一个域名一周只能重复更新5次。

We also have a Duplicate Certificate limit of 5 certificates per week. A certificate is considered a duplicate of an earlier certificate if they contain the exact same set of hostnames, ignoring capitalization and ordering of hostnames. For instance, if you requested a certificate for the names [www.example.com, example.com], you could request four more certificates for [www.example.com, example.com] during the week. If you changed the set of names by adding [blog.example.com], you would be able to request additional certificates.

        证书一定要针对指定的一个或多个域名,包括www也是要特别指定的,比如之前我注册了007.cn的https服务,但是访问http://7.3.3.6就是不行。

        可以一次指定多个域名的证书,包括主域名和若干个二级域名,但一个证书最多只可以包含100个二级域名。

        另外每周只能注册20个域名的证书,指的是一级域名。因此每周每个用户可以注册2000个唯一域名的证书。这个量对一般的用户已经足够了。

        还有,certbot-auto注册的https证书有效期都只有一个月,但它提供了自动更新证书的方法,首先使用。

[root@iZ2811jiwZ https]/certbot-auto  renew --dry-run
** DRY RUN: simulating 'certbot renew' close to cert expiry
**          (The test certificates below have not been saved.)
Congratulations, all renewals succeeded. The following certs have been renewed:
  /etc/letsencrypt/live/007.cn/fullchain.pem (success)
** DRY RUN: simulating 'certbot renew' close to cert expiry
**          (The test certificates above have not been saved.)

尝试进行一次模拟证书更新操作,如果没有问题,就可以在定时任务里加上任务,每月更新二次。

0 0 1,15 * * ./path/to/certbot-auto renew

        后记 :这是发表于2018年的博客文章,迁移至CSDN,但从目前的了解,这个免费的https工具好像进行了重大的变更改革,里面的方法可以做当参考和版本使用对比了解。 

  • 12
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

林戈的IT生涯

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值