差别
这里会显示出您选择的修订版和当前版本之间的差别。
| 两侧同时换到之前的修订记录前一修订版后一修订版 | 前一修订版 | ||
| it:server:security [2023-04-08 12:06] – [ACME 证书] goldentianya | it:server:security [2025-12-30 14:55] (当前版本) – [ACME 证书] goldentianya | ||
|---|---|---|---|
| 行 57: | 行 57: | ||
| </ | </ | ||
| - | ====== SSL 证书 ====== | ||
| - | 利用Cerbot(([[https:// | ||
| - | < | ||
| - | $ sudo apt install snap | ||
| - | $ sudo snap install core; sudo snap refresh core | ||
| - | $ sudo snap install --classic certbot | ||
| - | $ sudo ln -s / | ||
| - | $ sudo certbot --nginx # 应用此证书到Nginx服务器 | ||
| - | </ | ||
| - | 最后为两个域名生成证书,将这两份证书重新复制到别的主机,应该也可以用。 | ||
| - | < | ||
| - | Successfully received certificate. | ||
| - | Certificate is saved at: / | ||
| - | Key is saved at: / | ||
| - | This certificate expires on 2021-10-21. | ||
| - | These files will be updated when the certificate renews. | ||
| - | Certbot has set up a scheduled task to automatically renew this certificate in the background. | ||
| - | </ | ||
| - | 显示当前证书:< | ||
| - | 证书的有效期为三个,需要用下面命令定期更新:< | ||
| - | %%''</ | ||
| - | 或者添加定时任务 <color # | ||
| - | 接着到Nginx的conf配置文件中更改证书目录就可以了。 | ||
| - | 如果需要迁移的第二台服务器,直接压缩certbot的文件夹就好了。 <color # | ||
| - | 为主域名和下面的子域名申请通配证书 | ||
| - | (([[https:// | ||
| - | <code bash> | ||
| - | certbot certonly | ||
| - | # -d 为那些主机申请证书,如果是通配符,输入 *simperator.com | ||
| - | # –preferred-challenges dns,使用 DNS 方式校验域名所有权 | ||
| - | </ | ||
| - | <color # | ||
| - | 按照指示添加TXT记录,成功后存储在 <color # | ||
| - | |||
| - | 校验证书: | ||
| - | <code bash> | ||
| - | openssl x509 -in / | ||
| - | </ | ||
| - | |||
| - | < | ||
| - | // 显示证书的起始日期(Not Before)和到期日期(Not After) | ||
| - | openssl x509 -in < | ||
| - | // < | ||
| - | gnutls-cli -V --print-cert < | ||
| - | </ | ||
| - | |||
| - | 为域名更换证书 [[https:// | ||
| - | |||
| - | 更新邮件地址 | ||
| - | <code | download> | ||
| - | certbot register --update-registration --email < | ||
| - | certbot update_account --email [email protected] | ||
| - | </ | ||
| - | |||
| - | 打开 <color # | ||
| - | |||
| - | 为每一个子域名配置证书,如 xx.simperator.com,有多少个子网站就重复多少次。Certbot会找到Nginx并正确的配置。 | ||
| - | <code bash> | ||
| - | certbot --nginx -d fun.simperator.com | ||
| - | </ | ||
| - | |||
| - | |||
| - | 端口分配的设置参考[[https:// | ||
| - | |||
| - | **吊销证书**\\ | ||
| - | 严格来说不需要吊销一个证书,除非自己已经对这个域名失去控制。只要删除证书就好,三个月后会自动过期。并且< | ||
| - | < | ||
| - | certbot delete --cert-name MyDomain | ||
| - | </ | ||
| - | |||
| - | == sslforfree == | ||
| - | |||
| - | 另外一种申请证书的方式 [[https:// | ||
| - | ====== SSL 更新 ====== | ||
| - | 更新证书遇到错误: | ||
| - | < | ||
| - | sudo certbot renew --dry-run | ||
| - | |||
| - | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| - | Processing / | ||
| - | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| - | Failed to renew certificate simperator.com with error: The manual plugin is not working; there may be problems with your existing configuration. | ||
| - | The error was: PluginError(' | ||
| - | |||
| - | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| - | All renewals failed. The following certificates could not be renewed: | ||
| - | / | ||
| - | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| - | 1 renew failure(s), 0 parse failure(s) | ||
| - | Ask for help or search for solutions at https:// | ||
| - | </ | ||
| - | |||
| - | 尝试新的命令 | ||
| - | <code | download> | ||
| - | certbot certonly --manual -d *.simperator.com | ||
| - | </ | ||
| - | |||
| - | 更新证书后要重启服务器 <color # | ||
| - | |||
| - | 将 <color # | ||
| - | |||
| - | 為了防止過多的 TXT 紀錄,以後要刪除舊的紀錄。ionos 1小時, pi server 2小時。 | ||
| - | |||
| - | buypass TLS 证书可以6个月有效 | ||
| - | certbot certonly --standalone --agree-tos -d www.simperator.com -d simperator.com --server https:// | ||
| - | |||
| - | |||
| - | ====== ACME 证书 ====== | ||
| - | |||
| - | [[https:// | ||
| - | |||
| - | <code bash> | ||
| - | apt install -y socat | ||
| - | curl https:// | ||
| - | // ~/ | ||
| - | </ | ||
| - | |||
| - | 直接在Termial创建一个别名,可以方便使用 <color # | ||
| - | |||
| - | 注册证书 | ||
| - | <code bash> | ||
| - | ~/ | ||
| - | // 开通 80 和 443 端口,否则无法监听 | ||
| - | // 如果一直不通就加上参数 --server letsencrypt | ||
| - | ~/ | ||
| - | </ | ||
| - | |||
| - | 安装完成后会自动更新证书,查看crontab 会发现这条命令\\ | ||
| - | <wrap lo> | ||
| - | 40 0 * * * "/ | ||
| - | |||
| - | 拷贝证书到指定地点 | ||
| - | <code bash> | ||
| - | ~/ | ||
| - | |||
| - | </ | ||
| - | | ||
| - | <wrap em> | ||
| - | |||
| - | **为 nginx 配置证书** | ||
| - | 以域名 ionos.simperator.top 为例 | ||
| - | |||
| - | 1. 申请证书 <color # | ||
| - | |||
| - | 2. 创建文件夹 <color # | ||
| - | |||
| - | 3. 拷贝证书 | ||
| - | <code bash> | ||
| - | ~/ | ||
| - | --key-file | ||
| - | --fullchain-file | ||
| - | --reloadcmd | ||
| - | </ | ||
| - | |||
| - | 4 配置 conf 文件 | ||
| - | < | ||
| - | ssl_certificate "/ | ||
| - | ssl_certificate_key "/ | ||
| - | ssl_session_cache shared: | ||
| - | ssl_session_timeout | ||
| - | ssl_ciphers HIGH: | ||
| - | ssl_prefer_server_ciphers on; | ||
| - | |||
| - | # Load configuration files for the default server block. | ||
| - | include / | ||
| - | </ | ||
| - | |||
| - | 查看证书 <wrap em> | ||
| - | |||
| - | <WRAP center round important 60%> | ||
| - | cloudflare 现在已经不支持通过API设置.cf, | ||
| - | </ | ||
| - | |||
| - | |||
| - | ===== cloudflare ===== | ||
| - | |||
| - | 托管在 cloudflare 上的域名参考 [[https:// | ||
| - | |||
| - | 定时任务更新证书,并重新加载 nginx | ||
| - | |||
| - | < | ||
| - | 0 3 15 */2 * acme.sh --installcert -d simperator.com --fullchain-file / | ||
| - | </ | ||
| - | |||
| - | 自动更新 <color # | ||
| - | |||
| - | 其实可以使用 cloudflare 的源服务器证书。需要开启 | ||
| - | - 完全加密 | ||
| - | - 始终使用 HTTPS | ||
| - | - 打开小黄朵 | ||
| - | - 配置通配的边缘证书 | ||
| - | |||
| - | <WRAP center round tip 100%> | ||
| - | 您的域/ | ||
| - | Cloudflare 的 SSL 仅在您验证了根或 www DNS 记录的 SSL 证书后,才会向您网站的访问者显示,方法是在仪表板中将这些记录涂成橙色。如果 DNS 记录是灰色的,则 Cloudflare 颁发的 SSL 证书将不存在。 | ||
| - | </ | ||
| | | ||
| - | {{tag> | + | {{tag> |
