{"id":241,"date":"2024-11-23T22:21:44","date_gmt":"2024-11-23T14:21:44","guid":{"rendered":"https:\/\/zhzxs.asia\/?p=241"},"modified":"2024-11-23T22:24:09","modified_gmt":"2024-11-23T14:24:09","slug":"1732371662","status":"publish","type":"post","link":"https:\/\/www.zhzxs.site\/index.php\/2024\/11\/23\/1732371662\/","title":{"rendered":"Let\u2019s Encrypt \u53ca Certbot \u7b80\u4ecb"},"content":{"rendered":"\n<ul class=\"wp-block-list\">\n<li><strong>Let\u2019s Encrypt<\/strong>\uff1a<br>\u4e00\u4e2a\u514d\u8d39\u7684\u3001\u81ea\u52a8\u5316\u7684\u8bc1\u4e66\u9881\u53d1\u673a\u6784\uff08CA\uff09\uff0c\u901a\u8fc7\u9a8c\u8bc1\u4f60\u5bf9\u57df\u540d\u7684\u63a7\u5236\u6743\uff0c\u9881\u53d1 SSL\/TLS \u8bc1\u4e66\u3002<\/li>\n\n\n\n<li><strong>Certbot<\/strong>\uff1a<br>Let\u2019s Encrypt \u63d0\u4f9b\u7684\u5f00\u6e90\u5ba2\u6237\u7aef\u5de5\u5177\uff0c\u7528\u4e8e\u81ea\u52a8\u7533\u8bf7\u3001\u7eed\u8ba2\u548c\u5b89\u88c5\u8bc1\u4e66\u3002<\/li>\n\n\n\n<li>\u5173\u4e8eSSl\u7684\u4e00\u4e9b\u77e5\u8bc6\u53c2\u8003\u8fd9\u7bc7\u6587\u7ae0<a href=\"https:\/\/www.zhzxs.site\/index.php\/2024\/11\/23\/1732371535\/\">https:\/\/www.zhzxs.site\/index.php\/2024\/11\/23\/1732371535\/<\/a><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. Certbot \u7684\u5de5\u4f5c\u539f\u7406<\/strong><\/h3>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\u6b65\u9aa4\u4e00\uff1a\u9a8c\u8bc1\u57df\u540d\u63a7\u5236\u6743<\/strong><\/h4>\n\n\n\n<p>\u5f53\u4f60\u8fd0\u884c <code>sudo certbot --apache<\/code>\uff0cCertbot \u4f1a\u9996\u5148\u9a8c\u8bc1\u4f60\u5bf9\u76ee\u6807\u57df\u540d\u7684\u63a7\u5236\u6743\u3002\u8fd9\u662f\u901a\u8fc7\u4ee5\u4e0b\u4e24\u79cd\u65b9\u5f0f\u4e4b\u4e00\u5b9e\u73b0\u7684\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>HTTP-01 \u9a8c\u8bc1\uff08\u9ed8\u8ba4\u65b9\u5f0f\uff09<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>Certbot \u4f1a\u5728\u4f60\u7684\u7f51\u7ad9\u6839\u76ee\u5f55\u751f\u6210\u4e00\u4e2a\u4e34\u65f6\u6587\u4ef6\uff08<code>.well-known\/acme-challenge\/&lt;token&gt;<\/code>\uff09\u3002<\/li>\n\n\n\n<li>Let\u2019s Encrypt \u7684\u670d\u52a1\u5668\u4f1a\u5c1d\u8bd5\u8bbf\u95ee\u8fd9\u4e2a\u6587\u4ef6\uff0c\u4f8b\u5982\uff1aarduinoCopy code<code>http:\/\/example.com\/.well-known\/acme-challenge\/&lt;token&gt;<\/code><\/li>\n\n\n\n<li>\u5982\u679c\u8bbf\u95ee\u6210\u529f\uff0c\u8bf4\u660e\u4f60\u786e\u5b9e\u63a7\u5236\u4e86 <code>example.com<\/code> \u7684\u57df\u540d\u3002<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>DNS-01 \u9a8c\u8bc1\uff08\u5907\u7528\u65b9\u5f0f\uff09<\/strong>\uff1a\n<ul class=\"wp-block-list\">\n<li>Certbot \u8981\u6c42\u4f60\u5728\u57df\u540d\u7684 DNS \u8bb0\u5f55\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u7279\u5b9a\u7684 TXT \u8bb0\u5f55\u3002<\/li>\n\n\n\n<li>Let\u2019s Encrypt \u9a8c\u8bc1 DNS \u8bb0\u5f55\u540e\u9881\u53d1\u8bc1\u4e66\uff08\u9002\u7528\u4e8e\u9700\u8981\u4e3a\u672a\u5f00\u653e HTTP \u670d\u52a1\u7684\u57df\u540d\u7533\u8bf7\u8bc1\u4e66\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\u6b65\u9aa4\u4e8c\uff1a\u7533\u8bf7\u8bc1\u4e66<\/strong><\/h4>\n\n\n\n<p>\u9a8c\u8bc1\u901a\u8fc7\u540e\uff0cCertbot \u4f1a\u5411 Let\u2019s Encrypt \u8bf7\u6c42\u9881\u53d1\u4e00\u4e2a\u8bc1\u4e66\u3002Let\u2019s Encrypt \u4f1a\u751f\u6210\u8bc1\u4e66\u6587\u4ef6\u5e76\u5c06\u5176\u53d1\u9001\u56de\u4f60\u7684\u670d\u52a1\u5668\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\u6b65\u9aa4\u4e09\uff1a\u914d\u7f6e Apache<\/strong><\/h4>\n\n\n\n<p>Certbot \u4f1a\u81ea\u52a8\u4fee\u6539 Apache \u7684\u914d\u7f6e\u6587\u4ef6\u4ee5\u542f\u7528 HTTPS\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u6dfb\u52a0\u6216\u4fee\u6539\u865a\u62df\u4e3b\u673a\u914d\u7f6e\u6587\u4ef6\uff1a\n<ul class=\"wp-block-list\">\n<li>\u8bbe\u7f6e <code>SSLEngine on<\/code>\u3002<\/li>\n\n\n\n<li>\u6307\u5b9a\u8bc1\u4e66\u6587\u4ef6\u8def\u5f84\uff08\u901a\u5e38\u662f <code>\/etc\/letsencrypt\/live\/&lt;domain&gt;\/<\/code>\uff09\u3002apacheCopy code<code>SSLCertificateFile \/etc\/letsencrypt\/live\/example.com\/fullchain.pem SSLCertificateKeyFile \/etc\/letsencrypt\/live\/example.com\/privkey.pem<\/code><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>\u914d\u7f6e HTTP \u5230 HTTPS \u7684\u81ea\u52a8\u91cd\u5b9a\u5411\u89c4\u5219\uff08\u53ef\u9009\uff09\u3002<\/li>\n<\/ul>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\u6b65\u9aa4\u56db\uff1a\u91cd\u542f Apache<\/strong><\/h4>\n\n\n\n<p>\u5b8c\u6210\u914d\u7f6e\u540e\uff0cCertbot \u4f1a\u81ea\u52a8\u91cd\u542f\u6216\u91cd\u65b0\u52a0\u8f7d Apache \u4ee5\u4f7f\u65b0\u8bc1\u4e66\u751f\u6548\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. Certbot \u7684\u81ea\u52a8\u5316\u4f18\u52bf<\/strong><\/h3>\n\n\n\n<p>Certbot \u7684\u5f3a\u5927\u4e4b\u5904\u5728\u4e8e\u81ea\u52a8\u5316\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u7533\u8bf7\u8bc1\u4e66\uff1a<\/strong> \u81ea\u52a8\u4e0e Let\u2019s Encrypt \u4ea4\u4e92\uff0c\u4e0d\u9700\u8981\u624b\u52a8\u4e0a\u4f20\u6587\u4ef6\u6216\u586b\u5199\u8868\u5355\u3002<\/li>\n\n\n\n<li><strong>\u4fee\u6539\u914d\u7f6e\uff1a<\/strong> \u81ea\u52a8\u5b9a\u4f4d Apache \u914d\u7f6e\u6587\u4ef6\u5e76\u63d2\u5165\u8bc1\u4e66\u8def\u5f84\u3001\u91cd\u5b9a\u5411\u89c4\u5219\u7b49\u3002<\/li>\n\n\n\n<li><strong>\u7eed\u8ba2\u8bc1\u4e66\uff1a<\/strong> Let\u2019s Encrypt \u7684\u8bc1\u4e66\u6709\u6548\u671f\u4e3a 90 \u5929\uff0cCertbot \u4f1a\u901a\u8fc7 <code>cron<\/code> \u6216 <code>systemd timer<\/code> \u81ea\u52a8\u5b9a\u671f\u7eed\u8ba2\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4f60\u53ef\u4ee5\u624b\u52a8\u6d4b\u8bd5\u7eed\u8ba2\u8fc7\u7a0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>sudo certbot renew --dry-run<br><\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. \u5982\u4f55\u9a8c\u8bc1\u8bc1\u4e66\u5199\u5165\u6210\u529f\uff1f<\/strong><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u68c0\u67e5\u914d\u7f6e\u6587\u4ef6\uff1a<\/strong> \u786e\u8ba4 Apache \u7684\u865a\u62df\u4e3b\u673a\u914d\u7f6e\u4e2d\u5305\u542b\u4ee5\u4e0b\u5185\u5bb9\uff1a<code>SSLCertificateFile \/etc\/letsencrypt\/live\/&lt;domain&gt;\/fullchain.pem SSLCertificateKeyFile \/etc\/letsencrypt\/live\/&lt;domain&gt;\/privkey.pem<\/code><\/li>\n\n\n\n<li><strong>\u9a8c\u8bc1\u8bc1\u4e66\uff1a<\/strong> \u8bbf\u95ee\u7f51\u7ad9\u7684 HTTPS URL\uff0c\u4f8b\u5982 <code>https:\/\/example.com<\/code>\uff0c\u68c0\u67e5\u6d4f\u89c8\u5668\u5730\u5740\u680f\u662f\u5426\u663e\u793a\u9501\u6807\u5fd7\u3002<\/li>\n\n\n\n<li><strong>\u67e5\u770b\u8bc1\u4e66\u6587\u4ef6\uff1a<\/strong> Certbot \u751f\u6210\u7684\u8bc1\u4e66\u6587\u4ef6\u901a\u5e38\u4fdd\u5b58\u5728 <code>\/etc\/letsencrypt\/live\/&lt;domain&gt;\/<\/code> \u76ee\u5f55\uff0c\u53ef\u4ee5\u624b\u52a8\u67e5\u770b\uff1a<code>sudo ls -l \/etc\/letsencrypt\/live\/&lt;domain&gt;\/<\/code><\/li>\n\n\n\n<li><strong>\u4f7f\u7528\u5728\u7ebf\u5de5\u5177\uff1a<\/strong> \u4f7f\u7528 <a>SSL Labs<\/a> \u6216\u7c7b\u4f3c\u5de5\u5177\u9a8c\u8bc1\u8bc1\u4e66\u7684\u6b63\u786e\u6027\u3002<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u603b\u7ed3<\/strong><\/h3>\n\n\n\n<p>Certbot \u80fd\u591f\u201c\u81ea\u52a8\u5199\u5165\u8bc1\u4e66\u201d\u5f97\u76ca\u4e8e\u4ee5\u4e0b\u5173\u952e\u70b9\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u4e0e Let\u2019s Encrypt \u7684\u4ea4\u4e92\uff1a<\/strong> Certbot \u81ea\u52a8\u7533\u8bf7\u548c\u9a8c\u8bc1\u8bc1\u4e66\u3002<\/li>\n\n\n\n<li><strong>\u6587\u4ef6\u7cfb\u7edf\u6743\u9650\uff1a<\/strong> Certbot \u5177\u6709\u8bbf\u95ee\u548c\u4fee\u6539 Apache \u914d\u7f6e\u6587\u4ef6\u7684\u6743\u9650\u3002<\/li>\n\n\n\n<li><strong>\u81ea\u52a8\u5316\u811a\u672c\uff1a<\/strong> Certbot \u81ea\u52a8\u5b8c\u6210\u914d\u7f6e\u548c\u91cd\u542f Apache\uff0c\u4f7f HTTPS \u914d\u7f6e\u751f\u6548\u3002<\/li>\n<\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Certbot \u7684\u5de5\u4f5c\u539f\u7406 \u6b65\u9aa4\u4e00\uff1a\u9a8c\u8bc1\u57df\u540d\u63a7\u5236\u6743 \u5f53\u4f60\u8fd0\u884c sudo certbot &#8211;apache [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":114,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[70,69,66],"class_list":["post-241","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-2","tag-certbot","tag-lets-encrypt","tag-66"],"_links":{"self":[{"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/posts\/241","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/comments?post=241"}],"version-history":[{"count":3,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/posts\/241\/revisions"}],"predecessor-version":[{"id":248,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/posts\/241\/revisions\/248"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/media\/114"}],"wp:attachment":[{"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/media?parent=241"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/categories?post=241"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhzxs.site\/index.php\/wp-json\/wp\/v2\/tags?post=241"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}