{"id":9187,"date":"2018-12-25T02:45:04","date_gmt":"2018-12-24T18:45:04","guid":{"rendered":"http:\/\/bohu.net\/blog\/?p=9187"},"modified":"2023-02-10T23:35:35","modified_gmt":"2023-02-10T15:35:35","slug":"%e5%85%8d%e8%b4%b9ssl%e8%af%81%e4%b9%a6-lets-encrypt-%e4%b8%8e-certbot-%e5%bb%b6%e6%9c%9f","status":"publish","type":"post","link":"https:\/\/www.bohu.net\/blog\/9187\/","title":{"rendered":"\u514d\u8d39SSL\u8bc1\u4e66 &#8211; Let&#8217;s Encrypt \u4e0e certbot \u5ef6\u671f"},"content":{"rendered":"\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"269\" height=\"105\" src=\"http:\/\/bohu.net\/blog\/wp-content\/uploads\/2018\/12\/https___letsencrypt.org_about_.png\" alt=\"\" class=\"wp-image-9188\"\/><\/figure>\n\n\n\n<p class=\"has-light-gray-background-color has-background\">\u7ed9\u7f51\u7ad9\u52a0\u4e86SSL\uff0c\u7528\u7684  <a rel=\"noreferrer noopener\" aria-label=\"\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\" href=\"https:\/\/letsencrypt.org\/\" target=\"_blank\">Let&#8217;s Encrypt <\/a> \u3002\u540e\u6765\u770b\u6709\u6548\u671f\u53ea\u670990\u5929\uff0c\u5b98\u7f51\u63a8\u8350\u7528 <a href=\"https:\/\/certbot.eff.org\/\">certbot<\/a>&nbsp; \u5ef6\u671f\uff0c\u5f00\u59cb\u611f\u89c9\u633a\u9ebb\u70e6\uff0c\u4f46\u770b\u5230\u4e00\u7bc7\u6587\u7ae0\uff0c\u5199\u7684\u5f88\u597d\uff0c\u8f6c\u8d34\u7559\u5b58\u4e00\u4e0b\uff01<\/p>\n\n\n\n<p><a href=\"https:\/\/ksmx.me\/letsencrypt-ssl-https\/\">\u6587\u7ae0\u51fa\u81ea\uff1ahttps:\/\/ksmx.me\/letsencrypt-ssl-https\/<\/a><\/p>\n\n\n\n<p>\u73b0\u5728\u7528&nbsp;<em>Let&#8217;s Encrypt<\/em>\u3002<em>StartSSL<\/em>&nbsp;\u7684\u514d\u8d39\u8bc1\u4e66\u6709\u6548\u671f\u662f1\u5e74\uff0c1\u5e74\u540e\u9700\u8981\u624b\u52a8\u66f4\u6362\u3002\u914d\u7f6e\u8fc7\u7a0b\u8fd8\u633a\u9ebb\u70e6\u7684\u3002<\/p>\n\n\n\n<p>\u66f4\u63a8\u8350&nbsp;<em>Let&#8217;s Encrypt<\/em>\uff0c\u867d\u7136\u6709\u6548\u671f\u53ea\u67093\u4e2a\u6708\uff0c\u4f46\u53ef\u4ee5\u7528&nbsp;<a href=\"https:\/\/certbot.eff.org\/\">certbot<\/a>&nbsp;\u81ea\u52a8\u7eed\u671f\uff0c\u5b8c\u5168\u4e0d\u53d7\u5f71\u54cd\u3002\u800c\u4e14&nbsp;<em>Let&#8217;s Encrypt<\/em>&nbsp;\u56e0\u4e3a\u6709\u4e86&nbsp;<a href=\"https:\/\/certbot.eff.org\/\">certbot<\/a>&nbsp;\u8fd9\u6837\u7684\u81ea\u52a8\u5316\u5de5\u5177\uff0c\u914d\u7f6e\u7ba1\u7406\u8d77\u6765\u975e\u5e38\u5bb9\u6613\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"letsencrypt\">\u751f\u6210 Let&#8217;s Encrypt \u8bc1\u4e66<\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"780\" height=\"430\" src=\"https:\/\/bohu.net\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2016-05-29-at-4-50-30-PM.png\" alt=\"\" class=\"wp-image-9803\" srcset=\"https:\/\/www.bohu.net\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2016-05-29-at-4-50-30-PM.png 780w, https:\/\/www.bohu.net\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2016-05-29-at-4-50-30-PM-300x165.png 300w, https:\/\/www.bohu.net\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2016-05-29-at-4-50-30-PM-768x423.png 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/figure>\n\n\n\n<p><em>Let&#8217;s Encrypt<\/em>&nbsp;\u8bc1\u4e66\u751f\u6210\u4e0d\u9700\u8981\u624b\u52a8\u8fdb\u884c\uff0c\u5b98\u65b9\u63a8\u8350&nbsp;<a href=\"https:\/\/certbot.eff.org\/\">certbot<\/a>&nbsp;\u8fd9\u5957\u81ea\u52a8\u5316\u5de5\u5177\u6765\u5b9e\u73b0\u30023\u6b65\u8f7b\u677e\u641e\u5b9a\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>\u4e0b\u8f7d\u5b89\u88c5 certbot (Let\u2019s Encrypt\u9879\u76ee\u7684\u81ea\u52a8\u5316\u5de5\u5177)<\/li>\n\n\n\n<li>\u521b\u5efa\u914d\u7f6e\u6587\u4ef6<\/li>\n\n\n\n<li>\u6267\u884c\u8bc1\u4e66\u81ea\u52a8\u5316\u751f\u6210\u547d\u4ee4<\/li>\n<\/ol>\n\n\n\n<p>\u4e0b\u9762\u7684\u6559\u7a0b\u8fd0\u884c\u5728 Arch Linux \u4e0a\uff0c\u5176\u4ed6\u64cd\u4f5c\u7cfb\u7edf\u4e5f\u5927\u540c\u5c0f\u5f02\u3002\u4f60\u53ef\u4ee5\u5728&nbsp;<a href=\"https:\/\/certbot.eff.org\/\">certbot<\/a>&nbsp;\u7f51\u7ad9\u4e0a\uff0c\u9009\u62e9\u4f60\u7684 Web Server \u548c \u64cd\u4f5c\u7cfb\u7edf\uff0c\u5c31\u80fd\u770b\u5230\u5bf9\u5e94\u7684\u5b89\u88c5\u548c\u914d\u7f6e\u6559\u7a0b\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1certbot\">1. \u4e0b\u8f7d\u5b89\u88c5&nbsp;<a href=\"https:\/\/www.archlinux.org\/packages\/community\/any\/certbot\/\">certbot<\/a><\/h3>\n\n\n\n<p>\u5728 Arch Linux \u4e0a\uff0c\u5b89\u88c5\u5f88\u7b80\u5355\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo pacman \uff0dSyu\n$ sudo pacman -S certbot\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2\">2. \u521b\u5efa\u914d\u7f6e\u6587\u4ef6<\/h3>\n\n\n\n<p>\u5148\u521b\u5efa\u5b58\u653e\u914d\u7f6e\u6587\u4ef6\u7684\u6587\u4ef6\u5939\uff1a<\/p>\n\n\n\n<p><code>$ sudo mkdir \/etc\/letsencrypt\/configs<\/code><\/p>\n\n\n\n<p>\u7f16\u8f91\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n\n\n\n<p><code>$ sudo vim \/etc\/letsencrypt\/configs\/example.com.conf<\/code><\/p>\n\n\n\n<p>\u628a&nbsp;<a href=\"http:\/\/example.com\/\">example.com<\/a>&nbsp;\u66ff\u6362\u6210\u81ea\u5df1\u7684\u57df\u540d\uff0c\u914d\u7f6e\u6587\u4ef6\u5185\u5bb9\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># \u5199\u4f60\u7684\u57df\u540d\u548c\u90ae\u7bb1\ndomains = example.com\nrsa-key-size = 2048\nemail = your-email@example.com\ntext = True\n\n# \u628a\u4e0b\u9762\u7684\u8def\u5f84\u4fee\u6539\u4e3a example.com \u7684\u76ee\u5f55\u4f4d\u7f6e\nauthenticator = webroot\nwebroot-path = \/var\/www\/example\n<\/code><\/pre>\n\n\n\n<p>\u8fd9\u91cc\u9700\u8981\u89e3\u91ca\u4e00\u4e0b\uff0c\u4e0a\u9762\u914d\u7f6e\u6587\u4ef6\u7528\u4e86 webroot \u7684\u9a8c\u8bc1\u65b9\u6cd5\uff0c\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u5df2\u7ecf\u6709\u4e00\u4e2a Web Server \u8fd0\u884c\u4e2d\u7684\u60c5\u51b5\u3002certbot \u4f1a\u81ea\u52a8\u5728&nbsp;<code>\/var\/www\/example<\/code>&nbsp;\u4e0b\u9762\u521b\u5efa\u4e00\u4e2a\u9690\u85cf\u6587\u4ef6&nbsp;<code>.well-known\/acme-challenge<\/code>&nbsp;\uff0c\u901a\u8fc7\u8bf7\u6c42\u8fd9\u4e2a\u6587\u4ef6\u6765\u9a8c\u8bc1&nbsp;<a href=\"http:\/\/example.com\/\">example.com<\/a>&nbsp;\u786e\u5b9e\u5c5e\u4e8e\u4f60\u3002\u5916\u7f51\u670d\u52a1\u5668\u8bbf\u95ee&nbsp;<a href=\"http:\/\/www.example.com\/.well-known\/acme-challenge\">http:\/\/www.example.com\/.well-known\/acme-challenge<\/a>&nbsp;\uff0c\u5982\u679c\u8bbf\u95ee\u6210\u529f\u5219\u9a8c\u8bc1OK\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u4e0d\u9700\u8981\u624b\u52a8\u521b\u5efa\u8fd9\u4e2a\u6587\u4ef6\uff0ccertbot \u4f1a\u6839\u636e\u914d\u7f6e\u6587\u4ef6\u81ea\u52a8\u5b8c\u6210\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3\">3. \u6267\u884c\u8bc1\u4e66\u81ea\u52a8\u5316\u751f\u6210\u547d\u4ee4<\/h3>\n\n\n\n<p>\u4e00\u5207\u5c31\u7eea\uff0c\u6211\u4eec\u73b0\u5728\u53ef\u4ee5\u8fd0\u884c certbot \u4e86\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo certbot -c \/etc\/letsencrypt\/configs\/example.com.conf certonly\n\n## \u7247\u523b\u4e4b\u540e\uff0c\u770b\u5230\u4e0b\u9762\u5185\u5bb9\u5c31\u662f\u6210\u529f\u4e86\nIMPORTANT NOTES:\n - Congratulations! Your certificate and chain have been saved at \/etc\/letsencrypt\/live\/example.com\/fullchain.pem.\n<\/code><\/pre>\n\n\n\n<p>\u5982\u679c\u8fd0\u884c\u987a\u5229\uff0c\u6240\u6709\u670d\u52a1\u5668\u6240\u9700\u8981\u7684\u8bc1\u4e66\u5c31\u5df2\u7ecf\u751f\u6210\u597d\u4e86\u3002\u4ed6\u4eec\u88ab\u653e\u5728\u4e86&nbsp;<code>\/etc\/letsencrypt\/live\/example.com\/<\/code>&nbsp;\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ ls \/etc\/letsencrypt\/live\/example.com\/\ncert.pem #server cert only\nprivkey.pem #private key\nchain.pem #intermediates\nfullchain.pem #server cert + intermediates\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"nginx\">\u914d\u7f6e Nginx \u52a0\u5165\u8bc1\u4e66<\/h2>\n\n\n\n<p>\u5230\u8fd9\u91cc\u5df2\u7ecf\u6210\u529f\u4e00\u5927\u534a\u4e86\uff0c\u53ea\u9700\u8981\u914d\u7f6e Nginx \u652f\u6301\u521a\u521a\u751f\u6210\u7684\u8bc1\u4e66\u3002\u800c\u4e14\u8fd9\u4e2a\u914d\u7f6e\u6709\u6700\u4f73\u5b9e\u8df5\u53ef\u4ee5\u53c2\u8003\uff0c\u8bbf\u95ee\uff1a<a href=\"https:\/\/mozilla.github.io\/server-side-tls\/ssl-config-generator\/\">Mozilla SSL Configuration Generator<\/a>\uff0c\u8fd9\u662f Mozilla \u641e\u5f97\u4e00\u4e2a HTTPS \u914d\u7f6e\u6587\u4ef6\u81ea\u52a8\u751f\u6210\u5668\uff0c\u652f\u6301 Apache\uff0cNginx \u7b49\u591a\u79cd\u670d\u52a1\u5668\u3002\u6309\u7167\u8fd9\u4e2a\u914d\u7f6e\u6587\u4ef6\uff0c\u9009\u62e9&nbsp;<strong>Intermediate<\/strong>&nbsp;\u7684\u517c\u5bb9\u6027\u3002\u8fd9\u91cc\u751f\u6210\u7684\u914d\u7f6e\u6587\u4ef6\u662f\u4e1a\u754c\u6700\u4f73\u5b9e\u8df5\u548c\u7ed3\u679c\uff0c\u8ba9 Nginx \u6253\u5f00\u4e86\u5404\u79cd\u589e\u52a0\u5b89\u5168\u6027\u548c\u6027\u80fd\u7684\u53c2\u6570\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"913\" height=\"585\" src=\"https:\/\/bohu.net\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2016-05-29-at-6-01-10-PM.png\" alt=\"\" class=\"wp-image-9805\" srcset=\"https:\/\/www.bohu.net\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2016-05-29-at-6-01-10-PM.png 913w, https:\/\/www.bohu.net\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2016-05-29-at-6-01-10-PM-300x192.png 300w, https:\/\/www.bohu.net\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2016-05-29-at-6-01-10-PM-768x492.png 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p>\u9ed8\u8ba4\u914d\u7f6e\u6587\u4ef6\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>server {\n    listen 80 default_server;\n    listen &#91;::]:80 default_server;\n\n    # Redirect all HTTP requests to HTTPS with a 301 Moved Permanently response.\n    return 301 https:\/\/$host$request_uri;\n}\n\nserver {\n    listen 443 ssl http2;\n    listen &#91;::]:443 ssl http2;\n\n    # certs sent to the client in SERVER HELLO are concatenated in ssl_certificate\n    ssl_certificate \/path\/to\/signed_cert_plus_intermediates;\n    ssl_certificate_key \/path\/to\/private_key;\n    ssl_session_timeout 1d;\n    ssl_session_cache shared:SSL:50m;\n    ssl_session_tickets off;\n\n    # Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits\n    ssl_dhparam \/path\/to\/dhparam.pem;\n\n    # intermediate configuration. tweak to your needs.\n    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;\n    ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';\n    ssl_prefer_server_ciphers on;\n\n    # HSTS (ngx_http_headers_module is required) (15768000 seconds = 6 months)\n    add_header Strict-Transport-Security max-age=15768000;\n\n    # OCSP Stapling ---\n    # fetch OCSP records from URL in ssl_certificate and cache them\n    ssl_stapling on;\n    ssl_stapling_verify on;\n\n    ## verify chain of trust of OCSP response using Root CA and Intermediate certs\n    ssl_trusted_certificate \/path\/to\/root_CA_cert_plus_intermediates;\n\n    resolver &lt;IP DNS resolver&gt;;\n\n    ....\n}\n<\/code><\/pre>\n\n\n\n<p>\u8bf7\u6839\u636e\u81ea\u5df1\u7684\u670d\u52a1\u914d\u7f6e\u4fee\u6539\u548c\u6dfb\u52a0\u5185\u5bb9\uff0c<strong>\u91cd\u70b9\u53ea\u9700\u8981\u5173\u6ce86\u884c<\/strong>\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>server {\n\tlisten 443 ssl http2;\n\t....\n\tssl_certificate \/etc\/letsencrypt\/live\/example.com\/fullchain.pem;\n\tssl_certificate_key \/etc\/letsencrypt\/live\/example.com\/privkey.pem;\n\tssl_dhparam \/etc\/nginx\/ssl\/dhparam.pem;\n\n\tssl_trusted_certificate \/etc\/letsencrypt\/live\/example.com\/root_ca_cert_plus_intermediates;\n\n\tresolver &lt;IP DNS resolver&gt;;\n\t....\n}\n<\/code><\/pre>\n\n\n\n<p>\u8fd96\u884c\u4e2d\uff0c\u90e8\u5206\u6587\u4ef6\u8fd8\u4e0d\u5b58\u5728\uff0c\u9010\u4e2a\u8bf4\u660e\u3002<\/p>\n\n\n\n<p>\u9996\u5148\u662f\u7b2c\u4e00\u884c&nbsp;<code>listen 443 ssl http2;<\/code>&nbsp;\u4f5c\u7528\u662f\u542f\u7528 Nginx \u7684&nbsp;<a href=\"https:\/\/nginx.org\/en\/docs\/http\/ngx_http_v2_module.html\">ngx_http_v2_module \u6a21\u5757<\/a>&nbsp;\u652f\u6301 HTTP2\uff0cNginx \u7248\u672c\u9700\u8981\u9ad8\u4e8e 1.9.5\uff0c\u4e14\u7f16\u8bd1\u65f6\u9700\u8981\u8bbe\u7f6e&nbsp;<code>--with-http_v2_module<\/code>&nbsp;\u3002Arch Linux \u7684 Nginx \u5b89\u88c5\u5305\u4e2d\u5df2\u7ecf\u7f16\u8bd1\u4e86\u8fd9\u4e2a\u6a21\u5757\uff0c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528\u3002\u5982\u679c\u4f60\u7684 Linux \u53d1\u884c\u7248\u672c\u4e2d\u7684 Nginx \u5e76\u4e0d\u652f\u6301\u8fd9\u4e2a\u6a21\u5757\uff0c\u53ef\u4ee5\u81ea\u884c Google \u5982\u4f55\u52a0\u4e0a\u3002<\/p>\n\n\n\n<p><code>ssl_certificate<\/code>&nbsp;\u548c&nbsp;<code>ssl_certificate_key<\/code>&nbsp;\uff0c\u5206\u522b\u5bf9\u5e94&nbsp;<code>fullchain.pem<\/code>&nbsp;\u548c&nbsp;<code>privkey.pem<\/code>\uff0c\u8fd92\u4e2a\u6587\u4ef6\u662f\u4e4b\u524d\u5c31\u751f\u6210\u597d\u7684\u8bc1\u4e66\u548c\u5bc6\u94a5\u3002<\/p>\n\n\n\n<p><code>ssl_dhparam<\/code>&nbsp;\u901a\u8fc7\u4e0b\u9762\u547d\u4ee4\u751f\u6210\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo mkdir \/etc\/nginx\/ssl\n$ sudo openssl dhparam -out \/etc\/nginx\/ssl\/dhparam.pem 2048\n<\/code><\/pre>\n\n\n\n<p>\uff08\u53ef\u9009\uff09<code>ssl_trusted_certificate<\/code>&nbsp;\u9700\u8981\u4e0b\u8f7d&nbsp;<em>Let&#8217;s Encrypt<\/em>&nbsp;\u7684&nbsp;<a href=\"https:\/\/letsencrypt.org\/certificates\/\">Root Certificates<\/a>\uff0c\u4e0d\u8fc7\u6839\u636e&nbsp;<a href=\"http:\/\/nginx.org\/en\/docs\/http\/ngx_http_ssl_module.html#ssl_stapling\">Nginx \u5b98\u65b9\u6587\u6863<\/a>&nbsp;\u6240\u8bf4\uff0c<code>ssl_certificate<\/code>&nbsp;\u5982\u679c\u5df2\u7ecf\u5305\u542b\u4e86&nbsp;<code>intermediates<\/code>&nbsp;\u5c31\u4e0d\u518d\u9700\u8981\u63d0\u4f9b&nbsp;<code>ssl_trusted_certificate<\/code>\uff0c\u8fd9\u4e00\u6b65\u53ef\u4ee5\u7701\u7565\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ cd \/etc\/letsencrypt\/live\/example.com\n$ sudo wget https:\/\/letsencrypt.org\/certs\/isrgrootx1.pem\n$ sudo mv isrgrootx1.pem root.pem\n$ sudo cat root.pem chain.pem &gt; root_ca_cert_plus_intermediates\n<\/code><\/pre>\n\n\n\n<p><code>resolver<\/code>&nbsp;\u7684\u4f5c\u7528\u662f \u201cresolve names of upstream servers into addresses\u201d\uff0c \u5728\u9019\u500b\u914d\u7f6e\u4e2d\uff0cresolver \u662f\u7528\u4f86\u89e3\u6790 OCSP \u670d\u52d9\u5668\u7684\u57df\u540d\u7684\uff0c\u5efa\u8bae\u586b\u5199\u4f60\u7684 VPS \u63d0\u4f9b\u5546\u7684 DNS \u670d\u52a1\u5668\uff0c\u4f8b\u5982\u6211\u7684 VPN \u5728 Linode\uff0cDNS\u670d\u52a1\u5668\u586b\u5199\uff1a<\/p>\n\n\n\n<p><code>resolver 106.187.90.5 106.187.93.5;<\/code><\/p>\n\n\n\n<p>Nginx \u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u91cd\u542f\u540e\uff0c\u7528\u6d4f\u89c8\u5668\u6d4b\u8bd5\u662f\u5426\u4e00\u5207\u6b63\u5e38\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo systemctl restart nginx\n<\/code><\/pre>\n\n\n\n<p>\u8fd9\u65f6\u5019\u4f60\u7684\u7ad9\u70b9\u5e94\u8be5\u9ed8\u8ba4\u5f3a\u5236\u4f7f\u7528\u4e86 HTTPS\uff0c\u5e76\u4e14\u6d4f\u89c8\u5668\u5730\u5740\u680f\u5de6\u8fb9\u4f1a\u6709\u7eff\u8272\u7684\u5c0f\u9501\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"180\" height=\"36\" src=\"https:\/\/bohu.net\/blog\/wp-content\/uploads\/2018\/12\/Screen-Shot-2016-05-29-at-5-59-04-PM.png\" alt=\"\" class=\"wp-image-9806\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">\u81ea\u52a8\u5316\u5b9a\u671f\u66f4\u65b0\u8bc1\u4e66<\/h2>\n\n\n\n<p><em>Let&#8217;s Encrypt<\/em>&nbsp;\u8bc1\u4e66\u6709\u6548\u671f\u662f3\u4e2a\u6708\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7 certbot \u6765\u81ea\u52a8\u5316\u7eed\u671f\u3002<\/p>\n\n\n\n<p>\u5728 Arch Linux \u4e0a\uff0c\u6211\u4eec\u901a\u8fc7 systemd \u6765\u81ea\u52a8\u6267\u884c\u8bc1\u4e66\u7eed\u671f\u4efb\u52a1\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo vim \/etc\/systemd\/system\/letsencrypt.service\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;Unit]\nDescription=Let's Encrypt renewal\n\n&#91;Service]\nType=oneshot\nExecStart=\/usr\/bin\/certbot renew --quiet --agree-tos\nExecStartPost=\/bin\/systemctl reload nginx.service\n<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\u589e\u52a0\u4e00\u4e2a systemd timer \u6765\u89e6\u53d1\u8fd9\u4e2a\u670d\u52a1\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo vim \/etc\/systemd\/system\/letsencrypt.timer\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;Unit]\nDescription=Monthly renewal of Let's Encrypt's certificates\n\n&#91;Timer]\nOnCalendar=daily\nPersistent=true\n\n&#91;Install]\nWantedBy=timers.target\n<\/code><\/pre>\n\n\n\n<p>\u542f\u7528\u670d\u52a1\uff0c\u5f00\u542f timer\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo systemctl enable letsencrypt.timer\n$ sudo systemctl start letsencrypt.timer\n<\/code><\/pre>\n\n\n\n<p>\u4e0a\u9762\u4e24\u6761\u547d\u4ee4\u6267\u884c\u5b8c\u6bd5\u540e\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7&nbsp;<code>systemctl list-timers<\/code>&nbsp;\u5217\u51fa\u6240\u6709 systemd \u5b9a\u65f6\u670d\u52a1\u3002\u5f53\u4e2d\u53ef\u4ee5\u627e\u5230&nbsp;<code>letsencrypt.timer<\/code>&nbsp;\u5e76\u770b\u5230\u8fd0\u884c\u65f6\u95f4\u662f\u660e\u5929\u7684\u51cc\u666812\u70b9\u3002<\/p>\n\n\n\n<p>\u5728\u5176\u4ed6 Linux \u53d1\u884c\u7248\u672c\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 crontab \u6765\u8bbe\u5b9a\u5b9a\u65f6\u4efb\u52a1\uff0c\u81ea\u884c Google \u5427\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"ssl\">\u7528\u4e13\u4e1a\u5728\u7ebf\u5de5\u5177\u6d4b\u8bd5\u4f60\u7684\u670d\u52a1\u5668 SSL \u5b89\u5168\u6027<\/h2>\n\n\n\n<p><a href=\"https:\/\/www.ssllabs.com\/ssltest\/index.html\">Qualys SSL Labs<\/a>&nbsp;\u63d0\u4f9b\u4e86\u5168\u9762\u7684 SSL \u5b89\u5168\u6027\u6d4b\u8bd5\uff0c\u586b\u5199\u4f60\u7684\u7f51\u7ad9\u57df\u540d\uff0c\u7ed9\u81ea\u5df1\u7684 HTTPS \u914d\u7f6e\u6253\u4e2a\u5206\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u4f60\u5b8c\u5168\u6309\u7167\u6211\u4e0a\u9762\u6559\u7a0b\u914d\u7f6e\uff0c\u9075\u5faa\u4e86\u6700\u4f73\u5b9e\u8df5\uff0c<a href=\"https:\/\/www.ssllabs.com\/ssltest\/analyze.html?d=ksmx.me&amp;latest\">\u4f60\u5e94\u8be5\u548c\u6211\u4e00\u6837\u5f97\u5206\u662f A+<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed9\u7f51\u7ad9\u52a0\u4e86SSL\uff0c\u7528\u7684 Let&#8217;s Encrypt \u3002\u540e\u6765\u770b\u6709\u6548\u671f\u53ea\u670990\u5929\uff0c\u5b98\u7f51\u63a8\u8350\u7528 cert &hellip; <a href=\"https:\/\/www.bohu.net\/blog\/9187\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201c\u514d\u8d39SSL\u8bc1\u4e66 &#8211; Let&#8217;s Encrypt \u4e0e certbot \u5ef6\u671f\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":9188,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,10,11,20,22,23,28],"tags":[644],"class_list":["post-9187","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-vps","category-web","category-20","category-22","category-23","category-28","tag-ssl-lets-encrypt--certbot-"],"_links":{"self":[{"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/posts\/9187","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/comments?post=9187"}],"version-history":[{"count":2,"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/posts\/9187\/revisions"}],"predecessor-version":[{"id":9807,"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/posts\/9187\/revisions\/9807"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bohu.net\/blog\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/media?parent=9187"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/categories?post=9187"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bohu.net\/blog\/wp-json\/wp\/v2\/tags?post=9187"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}