{"id":141,"date":"2024-10-30T18:01:26","date_gmt":"2024-10-30T10:01:26","guid":{"rendered":"https:\/\/zhoujibin.com\/?p=141"},"modified":"2024-10-30T18:01:26","modified_gmt":"2024-10-30T10:01:26","slug":"%e5%85%8d%e8%b4%b9%e7%94%b3%e8%af%b7ssl%e8%af%81%e4%b9%a6","status":"publish","type":"post","link":"https:\/\/zhoujibin.com\/?p=141","title":{"rendered":"\u514d\u8d39\u7533\u8bf7ssl\u8bc1\u4e66"},"content":{"rendered":"\n<p>[TOC]<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">SSL\u8bc1\u4e66\u7b80\u4ecb<\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>SSL\u8bc1\u4e66\uff08Secure Sockets Layer Certificate\uff09\u662f\u4e00\u79cd\u6570\u5b57\u8bc1\u4e66\uff0c\u5b83\u5728\u73b0\u4ee3\u7f51\u7edc\u73af\u5883\u4e2d\u626e\u6f14\u7740\u81f3\u5173\u91cd\u8981\u7684\u89d2\u8272\uff0c\u4e3b\u8981\u7528\u4e8e\u5b9e\u73b0\u7f51\u7ad9\u548c\u5e94\u7528\u7a0b\u5e8f\u7684\u5b89\u5168\u901a\u4fe1\u3002SSL\u8bc1\u4e66\u9075\u5faaSSL\/TLS\u534f\u8bae\uff0c\u7531\u53d7\u4fe1\u4efb\u7684\u8bc1\u4e66\u9881\u53d1\u673a\u6784\uff08CA, Certificate Authority\uff09\u7b7e\u53d1\uff0c\u7ecf\u8fc7\u4e25\u683c\u7684\u8eab\u4efd\u9a8c\u8bc1\u8fc7\u7a0b\uff0c\u4ee5\u786e\u4fdd\u8bc1\u4e66\u6301\u6709\u8005\u7684\u771f\u5b9e\u8eab\u4efd\u3002<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">SSL\u8bc1\u4e66\u7684\u6838\u5fc3\u4f5c\u7528<\/h1>\n\n\n\n<p>\u670d\u52a1\u5668\u8eab\u4efd\u9a8c\u8bc1<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u8bc1\u660e\u7f51\u7ad9\u6216\u670d\u52a1\u5668\u7684\u6240\u6709\u6743\u548c\u5408\u6cd5\u6027\uff0c\u4f7f\u8bbf\u95ee\u8005\u80fd\u591f\u786e\u8ba4\u6b63\u5728\u4e0e\u6b63\u786e\u7684\u76ee\u6807\u8fdb\u884c\u4ea4\u4e92\uff0c\u907f\u514d\u88ab\u5047\u5192\u7f51\u7ad9\u6b3a\u9a97<\/code><\/pre>\n\n\n\n<p>\u6570\u636e\u52a0\u5bc6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u5728\u5ba2\u6237\u7aef\uff08\u5982Web\u6d4f\u89c8\u5668\uff09\u4e0e\u670d\u52a1\u5668\u4e4b\u95f4\u5efa\u7acb\u52a0\u5bc6\u901a\u9053\uff0c\u786e\u4fdd\u5728\u4e24\u8005\u95f4\u4f20\u8f93\u7684\u6570\u636e\uff08\u5982\u767b\u5f55\u51ed\u8bc1\u3001\u4ea4\u6613\u4fe1\u606f\u7b49\uff09\u4e0d\u88ab\u7b2c\u4e09\u65b9\u7a83\u53d6\u6216\u76d1\u542c\u3002<\/code><\/pre>\n\n\n\n<p>\u6570\u636e\u5b8c\u6574\u6027<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u901a\u8fc7\u6563\u5217\u7b97\u6cd5\u786e\u4fdd\u6570\u636e\u5728\u4f20\u8f93\u8fc7\u7a0b\u4e2d\u672a\u7ecf\u7be1\u6539\u3002\u4e00\u65e6\u7f51\u7ad9\u5b89\u88c5\u4e86\u6709\u6548\u7684SSL\u8bc1\u4e66\uff0c\u6d4f\u89c8\u5668\u5730\u5740\u680f\u901a\u5e38\u4f1a\u663e\u793a\u7eff\u8272\u9501\u56fe\u6807\u6216\u201cHTTPS\u201d\u524d\u7f00\uff0c\u8868\u793a\u8be5\u7f51\u7ad9\u542f\u7528\u4e86\u5b89\u5168\u94fe\u63a5\u3002\u8fd9\u5bf9\u4e8e\u7535\u5b50\u5546\u52a1\u3001\u7f51\u4e0a\u94f6\u884c\u3001\u4e2a\u4eba\u4fe1\u606f\u6536\u96c6\u7b49\u6d89\u53ca\u9690\u79c1\u548c\u654f\u611f\u4fe1\u606f\u4ea4\u6362\u7684\u5728\u7ebf\u670d\u52a1\u5c24\u5176\u91cd\u8981\uff0c\u6709\u52a9\u4e8e\u63d0\u5347\u7528\u6237\u4fe1\u4efb\u5ea6\u548c\u6574\u4f53\u7f51\u7edc\u5b89\u5168\u6c34\u5e73\u3002<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">SSL\u8bc1\u4e66\u9881\u53d1\u673a\u6784<\/h1>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Let&#8217;s Encrypt\uff08\u63d0\u4f9b\u514d\u8d39SSL\u8bc1\u4e66\u7684\u975e\u8425\u5229\u6027CA\uff09<\/li>\n\n\n\n<li>DigiCert<\/li>\n\n\n\n<li>Sectigo (\u539fComodo CA)<\/li>\n\n\n\n<li>GlobalSign\u2022GeoTrust<\/li>\n\n\n\n<li>Symantec (\u73b0\u5df2\u5408\u5e76\u81f3DigiCert\u54c1\u724c\u4e0b)<\/li>\n\n\n\n<li>Thawte<\/li>\n\n\n\n<li>RapidSSL<\/li>\n\n\n\n<li>AlphaSSL<\/li>\n\n\n\n<li>GoDaddy<\/li>\n\n\n\n<li>TrustAsia\uff08\u4e9a\u6d32\u8bda\u4fe1\uff0c\u4e2d\u56fdCA\uff09<\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\">\u670d\u52a1\u5668\u8bf4\u660e<\/h1>\n\n\n\n<p>\u53ef\u4f7f\u7528 lsb_release -a \u547d\u4ee4\u67e5\u770b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>LSB Version:    core-11.1.0ubuntu4-noarch:security-11.1.0ubuntu4-noarch\nDistributor ID:    Ubuntu\nDescription:    Ubuntu 22.04.4 LTS\nRelease:    22.04\nCodename:    jammy<\/code><\/pre>\n\n\n\n<h1 class=\"wp-block-heading\">\u7533\u8bf7Let&#8217;s Encrypt \u9881\u53d1\u7684ssl\u8bc1\u4e66<\/h1>\n\n\n\n<p>\u6b64\u6b21web\u670d\u52a1\u5668\u4f7f\u7528\u7684\u662fnginx\uff0c\u57df\u540d\u4e3a\uff1amy-domain.com\uff0c\u53ef\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u66ff\u6362<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4e0b\u8f7d\u811a\u672c<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>curl https:\/\/get.acme.sh | sh -s email=123@123.123\nsource ~\/.bashrc<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">nginx\u4e2d\u914d\u7f6e\u57df\u540d<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>server {\n        listen 80 default_server;\n        listen &#91;::]:80 default_server;\n\n\n        root \/var\/www\/html;\n\n        # Add index.php to the list if you are using PHP\n        index index.html index.htm index.nginx-debian.html;\n        # \u6b64\u5904\u914d\u7f6e\u57df\u540d\n        server_name my-domain.com;\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u7533\u8bf7\u8bc1\u4e66<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>acme.sh --issue -d my-domain.com --nginx<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b89\u88c5\u8bc1\u4e66<\/h2>\n\n\n\n<p>\u6b64\u6b65\u9aa4\u4f1a\u9ed8\u8ba4\u5c06key.pem \u3001cert.pem\u62f7\u8d1d\u5230\/etc\/nginx\/ssl\/my-domain.com\/\u76ee\u5f55\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>acme.sh --install-cert -d my-domain.com \\\n--key-file       \/etc\/nginx\/ssl\/my-domain.com\/key.pem  \\\n--fullchain-file \/etc\/nginx\/ssl\/my-domain.com\/cert.pem \\\n--reloadcmd     \"service nginx force-reload\"<\/code><\/pre>\n\n\n\n<p>\u53c2\u8003\uff1ahttps:\/\/github.com\/acmesh-official\/acme.sh\/wiki\/%E8%AF%B4%E6%98%8E<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u67e5\u770b\u5b89\u88c5\u7684\u8bc1\u4e66\u4fe1\u606f<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>acme.sh --info -d my-domain.com<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u914d\u7f6enginx\u8bc1\u4e66\u4fe1\u606f<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>server {\n    listen              443 ssl;\n    server_name         my-domain.com;\n    server_tokens       off; # \u7981\u6b62\u5728\u54cd\u5e94\u62a5\u6587\u4e2d\u5305\u542bNginx\u7248\u672c\u4fe1\u606f\n\n    # ssl\u8bc1\u4e66\u5730\u5740\n    ssl_certificate_key \/etc\/nginx\/ssl\/my-domain.com\/key.pem;\n    ssl_certificate     \/etc\/nginx\/ssl\/my-domain.com\/cert.pem;\n\n    # ssl\u9a8c\u8bc1\u76f8\u5173\u914d\u7f6e\n    ssl_session_timeout  5m;    #\u7f13\u5b58\u6709\u6548\u671f\n    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;    #\u52a0\u5bc6\u7b97\u6cd5\n    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;    #\u5b89\u5168\u94fe\u63a5\u53ef\u9009\u7684\u52a0\u5bc6\u534f\u8bae\n    ssl_prefer_server_ciphers on;   #\u4f7f\u7528\u670d\u52a1\u5668\u7aef\u7684\u9996\u9009\u7b97\u6cd5\n\n    if ($host != 'my-domain.com' ) {\n        return 301 https:\/\/my-domain.com$request_uri;\n    }\n\n    location \/ {\n       root   \/etc\/nginx\/web\/;\n       index  index.html index.htm;\n    }\n}\n\n# \u91cd\u8f7dnginx\nservice nginx reload<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u8bbf\u95ee\u5730\u5740<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>https:&#47;&#47;my-domain.com<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>[TOC] SSL\u8bc1\u4e66\u7b80\u4ecb SSL\u8bc1\u4e66\u7684\u6838\u5fc3\u4f5c\u7528 \u670d\u52a1\u5668\u8eab\u4efd\u9a8c\u8bc1 \u6570\u636e\u52a0\u5bc6 \u6570\u636e\u5b8c\u6574\u6027 SSL\u8bc1\u4e66\u9881\u53d1\u673a\u6784 \u670d [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[30,37],"class_list":["post-141","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux","tag-ssl"],"_links":{"self":[{"href":"https:\/\/zhoujibin.com\/index.php?rest_route=\/wp\/v2\/posts\/141"}],"collection":[{"href":"https:\/\/zhoujibin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zhoujibin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zhoujibin.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zhoujibin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=141"}],"version-history":[{"count":1,"href":"https:\/\/zhoujibin.com\/index.php?rest_route=\/wp\/v2\/posts\/141\/revisions"}],"predecessor-version":[{"id":142,"href":"https:\/\/zhoujibin.com\/index.php?rest_route=\/wp\/v2\/posts\/141\/revisions\/142"}],"wp:attachment":[{"href":"https:\/\/zhoujibin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zhoujibin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zhoujibin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}