最近一直扎根公司,连续加班,忙于工做,很久没能静下来写写东西了。php
恰好前段时间给我同事布置个生成 https 证书的任务,发现不少人都是寻求于阿里云、七牛等国内大厂提供的免费或者付费证书。python
但若是这些大厂不提供服务了呢?因此咱们有必要本身制做证书。nginx
因此今天给你们推荐一个工具 —— 「certbot」,能够快速生成证书,并且还能够和 apache、nginx 等完美结合使用。git
certbot 能够知足常规的软件和服务系统:web
Certbot is an easy-to-use automatic client that fetches and deploys SSL/TLS certificates for your webserver. Certbot was developed by EFF and others as a client for Let’s Encrypt and was previously known as “the official Let’s Encrypt client” or “the Let’s Encrypt Python client.” Certbot will also work with any other CAs that support the ACME protocol.apache
摘自:certbot.eff.org/about/centos
简单的说,就是 Let's Encrypt 这个免费、自动化、开放的证书签发服务的客户端工具,是用 Python 开发的。bash
接下来经过结合 CentOS 7 和 Nginx 环境来讲说如何安装使用 certbot。dom
根据官网 (certbot.eff.org/#centosrhel…) 的步骤来安装 certbot,发现会报 pyOpenSSL 版本低的问题,因此首先须要安装 pyOpenSSL 最新版:工具
1. 先卸载 pyOpenSSL
sudo yum erase pyOpenSSL
复制代码
2. 在 http://rpm.pbone.net/index.php3/stat/2/simple/2 搜 pyOpenSSL
3. 选择一个下载源下载:
wget ftp://mirror.switch.ch/pool/4/mirror/centos/7.4.1708/cloud/x86_64/openstack-ocata/python2-pyOpenSSL-16.2.0-3.el7.noarch.rpm
复制代码
4. 安装
sudo rpm -Uvh pyOpenSSL-0.15.1-1.el7.noarch.rpm
复制代码
只要一条命令便可:
sudo yum install certbot certbot-nginx
复制代码
使用也很方便,只要输入命令,而后根据提示便可:
certbot --nginx
复制代码
而后,让你选择哪一个域名须要 https 协议的:
不如所料的成功了:
看看运行效果吧:
最后根据官网的提示,须要作个定时器来时不时 renew 下:
0 0,12 * * * python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew
复制代码
由于时间关系,没有尝试使用 certbot 的其它功能,但对于如何生成 https 证书的小白来讲,我以为 certbot 提供极大的便利,固然如何本身徒手生成证书,或者使用 Let's Encrypt 生成证书,我相信市面上的教程不少,这里就再也不赘述了。
若是你以为 certbot 还不错,你也能够试试哦~~~
解决Received 1 certificate(s), first certificate had names 的问题
// centos 6.8 的环境下
sudo ./certbot-auto --nginx -d git.***.com
复制代码
「完」
coding01 期待您继续关注
也很感谢您能看到这了