打开网站提示不安全

本文记录了解决SSL证书过期,导致网站访问显示不安全的过程。首先通过crontab检查证书更新脚本,发现证书已设置为自动更新,并且下次更新时间为25号。然后手动执行更新命令,成功获取新证书,但访问网站仍然提示不安全。最后检查nginx配置确认证书路径无误,并执行nginx reload,成功解决网站安全问题。
摘要由CSDN通过智能技术生成

打开网站发现提示不安全,点击查看警告信息确认是使用的证书过期导致的。

登录aliyun主机查看定时更新证书的crontab:

# crontab -l
2 0 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null
 

可以看到每天半夜会检查更新一次,是不是脚本执行时出错了呢?

直接复制命令执行:

# "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh"
[2021年 01月 07日 星期四 22:00:13 CST] ===Starting cron===
[2021年 01月 07日 星期四 22:00:13 CST] Renew: 'tianlang.tech'
[2021年 01月 07日 星期四 22:00:13 CST] Skip, Next renewal time is: Mon Jan 25 16:03:12 UTC 2021
[2021年 01月 07日 星期四 22:00:13 CST] Add '--force' to force to renew.
[2021年 01月 07日 星期四 22:00:13 CST] Skipped tianlang.tech
[2021年 01月 07日 星期四 22:00:13 CST] ===End cron===
 

提示证书已经更新过了,下次更新要到25号,如果需要强制更新可以使用--force参数,那就强制更新吧:

# "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" --force
[2021年 01月 07日 星期四 22:01:20 CST] ===Starting cron===
[2021年 01月 07日 星期四 22:01:20 CST] Renew: 'tianlang.tech'
[2021年 01月 07日 星期四 22:01:21 CST] Multi domain='DNS:tianlang.tech,DNS:*.tianlang.tech'
[2021年 01月 07日 星期四 22:01:21 CST] Getting domain auth token for each domain
[2021年 01月 07日 星期四 22:01:30 CST] Getting webroot for domain='tianlang.tech'
[2021年 01月 07日 星期四 22:01:30 CST] Getting webroot for domain='*.tianlang.tech'
[2021年 01月 07日 星期四 22:01:30 CST] Adding txt value: hWwFGR9GQ8GwS3-vd0EaR7pa0eqflPDgHcVEOJdJD6k for domain:  _acme-challenge.tianlang.tech
[2021年 01月 07日 星期四 22:01:32 CST] The txt record is added: Success.
[2021年 01月 07日 星期四 22:01:32 CST] Adding txt value: Fs6aO8pvyNeOiErzAkYtZCZSZPcXcHX8inuDDZzld-8 for domain:  _acme-challenge.tianlang.tech
[2021年 01月 07日 星期四 22:01:34 CST] The txt record is added: Success.
[2021年 01月 07日 星期四 22:01:34 CST] Let's check each DNS record now. Sleep 20 seconds first.
[2021年 01月 07日 星期四 22:01:55 CST] Checking tianlang.tech for _acme-challenge.tianlang.tech
[2021年 01月 07日 星期四 22:01:59 CST] Domain tianlang.tech '_acme-challenge.tianlang.tech' success.
[2021年 01月 07日 星期四 22:01:59 CST] Checking tianlang.tech for _acme-challenge.tianlang.tech
[2021年 01月 07日 星期四 22:02:02 CST] Domain tianlang.tech '_acme-challenge.tianlang.tech' success.
[2021年 01月 07日 星期四 22:02:02 CST] All success, let's return
[2021年 01月 07日 星期四 22:02:02 CST] Verifying: tianlang.tech
[2021年 01月 07日 星期四 22:02:08 CST] Pending
[2021年 01月 07日 星期四 22:02:11 CST] Pending
[2021年 01月 07日 星期四 22:02:15 CST] Success
[2021年 01月 07日 星期四 22:02:15 CST] Verifying: *.tianlang.tech
[2021年 01月 07日 星期四 22:02:19 CST] Success
[2021年 01月 07日 星期四 22:02:19 CST] Removing DNS records.
[2021年 01月 07日 星期四 22:02:19 CST] Removing txt: hWwFGR9GQ8GwS3-vd0Eapa0eqfJdJD6k for domain: _acme-challenge.tianlang.tech
[2021年 01月 07日 星期四 22:02:22 CST] Removed: Success
[2021年 01月 07日 星期四 22:02:22 CST] Removing txt: Fs6aO8pvyNeOiErzAkYtZCZSZPcXinuDDZzld-8 for domain: _acme-challenge.tianlang.tech
[2021年 01月 07日 星期四 22:02:25 CST] Removed: Success
[2021年 01月 07日 星期四 22:02:25 CST] Verify finished, start to sign.
[2021年 01月 07日 星期四 22:02:25 CST] Lets finalize the order, Le_OrderFinalize: https://acme-v02.api.letsencrypt.org/acme/finalize/92657238/7....
[2021年 01月 07日 星期四 22:02:30 CST] Download cert, Le_LinkCert: https://acme-v02.api.letsencrypt.org/acme/cert/.....
[2021年 01月 07日 星期四 22:02:39 CST] Cert success.
-----BEGIN CERTIFICATE-----
......
-----END CERTIFICATE-----
[2021年 01月 07日 星期四 22:02:39 CST] Your cert is in  /root/.acme.sh/tianlang.tech/tianlang.tech.cer 
[2021年 01月 07日 星期四 22:02:39 CST] Your cert key is in  /root/.acme.sh/tianlang.tech/tianlang.tech.key 
[2021年 01月 07日 星期四 22:02:39 CST] The intermediate CA cert is in  /root/.acme.sh/tianlang.tech/ca.cer 
[2021年 01月 07日 星期四 22:02:39 CST] And the full chain certs is there:  /root/.acme.sh/tianlang.tech/fullchain.cer 
[2021年 01月 07日 星期四 22:02:39 CST] ===End cron===
 

更新成功后,访问www.tianlang.tech依然提示不安全,尴了个尬了.才想器是不是nginx没有重新加载证书或者加载证书不是新生成的,查看nignx配置:

# cat /etc/nginx/conf.d/https.www.tianlang.tech.conf 
server {
    listen       443 http2 ssl;
    ssl_certificate /root/.acme.sh/tianlang.tech/fullchain.cer;
    ssl_certificate_key /root/.acme.sh/tianlang.tech/tianlang.tech.key;
    ssl_trusted_certificate  /root/.acme.sh/tianlang.tech/ca.cer;

    server_name  tianlang.tech www.tianlang.tech;
    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    #location / {
    #    root   /home/www/web/www.zhuaniqiu.com;
    #    index  index.html index.htm;
    #}

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    location / {
        proxy_pass   http://127.0.0.1:8018;
    }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}
 

确认证书路径正确(可以匹配生成脚步执行日志).再执行nginx reload:

# nginx -s reload

终于可以正常访问了,一开始要是先检查证书是否是新的就好了,这样就可以确认是nignx没有reload还是证书没有更新的问题了,想当然了!

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

一个不安分的程序员

祝您财源广进

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

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

打赏作者

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

抵扣说明:

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

余额充值