https证书申请

下面介绍两种比较简单的申请方式:
使用网站
    https://freessl.cn/   在线免费申请有效期为一年的证书。     

    **获取certbot客户端**
wget https://dl.eff.org/certbot-auto
chmod a+x certbot-auto

**停止nginx/apache**
systemctl stop nginx

**生成证书**
./certbot-auto certonly --standalone --email `你的邮箱地址` -d `你的域名地址`
当前网站有多个域名时需在后面增加,例如:
./certbot-auto certonly --standalone --email `你的邮箱地址` -d `你的域名1` -d `你的域名2`

**查看生产的证书**
tree /etc/letsencrypt/live/
**将证书用于nginx**
 添加到server 字段下
    listen 443 ssl http2;
    server_name domain_name;
    root /usr/share/nginx/html;
    ssl_certificate   /etc/letsencrypt/live/domain_name/fullchain.pem;
    ssl_certificate_key  /etc/letsencrypt/live/domain_name/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了,下面进行自动续期操作**
将下面内容添加到任务计划就可以自动续期了。
0 0,12 * * * python -c 'import random; import time; time.sleep(random.random() * 3600)'      && certbot renew
**启动nginx/apache**
 systemctl start nginx

猜你喜欢

转载自blog.51cto.com/12328206/2452660