标签:site evel nal LLC red style 问题 new Opens
为了安全起见,现在开发微信服务号和IOS客户端等访问服务器端都要求使用https加密传输。
SSL证书是数字证书的一种,类似于驾驶证、护照和营业执照的电子副本。因为配置在服务器上,也称为SSL服务器证书。
Let’s Encrypt 也是一个 CA 机构,但这个 CA 机构是免费的!!!也就是说签发证书不需要任何费用。
现在讲解一下,如何在centos操作系统下,获得Lets Encrypt免费的ssl证书,并在nginx里配置使用。
安装Certbot客户端
Certbot是一个EPEL安装包,如果没有配置EPEL库,需要提前将库配置好。
运行以下命令安装Certbot:
$ sudo yum install certbot-nginx
2.使用Certbot生成证书
$ sudo certbot --authenticator standalone --installer nginx --pre-hook "nginx -s stop" --post-hook "nginx"
生成过程中需要输入域名,域名要提前进行解析。
3.修改nginx配置
certbot会在/etc/letsencrypt/live/目录下生成一个域名的目录,然后修改对应的nginx的配置。
ssl_certificate "/etc/letsencrypt/live/{域名}/fullchain.pem"; ssl_certificate_key "/etc/letsencrypt/live/{域名}/privkey.pem";
4.如何让证书永久免费呢?
Let‘s Encrypt证书有效期为90天,为了保证在过期前更新证书,Certbot提供了更新证书有效期的功能。使用以下功能可以进行更新:
$ sudo certbot renew --dry-run
也可以使用crontab自动更新证书有效期。
0 0,12 * * * python -c ‘import random; import time; time.sleep(random.random() * 3600)‘ && certbot renew
常见问题:
1. 生成证书的时候报错
Traceback (most recent call last):
File "/bin/certbot", line 9, in <module>
load_entry_point(‘certbot==1.6.0‘, ‘console_scripts‘, ‘certbot‘)()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2852, in load_entry_point
return ep.load()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2443, in load
return self.resolve()
File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2449, in resolve
module = __import__(self.module_name, fromlist=[‘__name__‘], level=0)
File "/usr/lib/python2.7/site-packages/certbot/main.py", line 2, in <module>
from certbot._internal import main as internal_main
File "/usr/lib/python2.7/site-packages/certbot/_internal/main.py", line 20, in <module>
from certbot._internal import account
File "/usr/lib/python2.7/site-packages/certbot/_internal/account.py", line 18, in <module>
from acme.client import ClientBase # pylint: disable=unused-import
File "/usr/lib/python2.7/site-packages/acme/client.py", line 39, in <module>
requests.packages.urllib3.contrib.pyopenssl.inject_into_urllib3() # type: ignore
File "/usr/lib/python2.7/site-packages/urllib3/contrib/pyopenssl.py", line 118, in inject_into_urllib3
_validate_dependencies_met()
File "/usr/lib/python2.7/site-packages/urllib3/contrib/pyopenssl.py", line 160, in _validate_dependencies_met
"‘pyOpenSSL‘ module missing required functionality. "
ImportError: ‘pyOpenSSL‘ module missing required functionality. Try upgrading to v0.14 or newer.
解决:
pip install --upgrade --force-reinstall ‘requests==2.6.0‘
标签:site evel nal LLC red style 问题 new Opens
原文地址:https://www.cnblogs.com/xingxia/p/web_ssl.html