{"id":3075,"date":"2016-12-17T22:32:38","date_gmt":"2016-12-17T14:32:38","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=3075"},"modified":"2016-12-17T22:32:38","modified_gmt":"2016-12-17T14:32:38","slug":"%e5%a6%82%e4%bd%95%e8%87%aa%e7%ad%be%e5%8f%91https%e8%af%81%e4%b9%a6","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/3075.html","title":{"rendered":"\u5982\u4f55\u81ea\u7b7e\u53d1HTTPS\u8bc1\u4e66"},"content":{"rendered":"<p>=Start=<\/p>\n<h4>\u7f18\u7531\uff1a<\/h4>\n<p>\u5728\u6d4b\u8bd5\u7ed9Nginx\u65b0\u589e<a href=\"https:\/\/github.com\/cuber\/ngx_http_google_filter_module\">\u6a21\u5757<\/a>\u7684\u65f6\u5019\u60f3\u8bd5\u8bd5HTTPS\u7684\u914d\u7f6e\u65b9\u5f0f\uff0c\u4f46\u662f\u624b\u4e0a\u53c8\u6ca1\u6709\u591a\u7684\u57df\u540d\u4e86\uff0c\u539f\u672c\u60f3\u7740\u662f\u7528IP\u7533\u8bf7\u4e00\u4e2a\u514d\u8d39\u7684Let&#8217;s Encrypt\u7684HTTPS\u8bc1\u4e66\u7684\uff0c\u7167\u7740\u300c<a href=\"https:\/\/imququ.com\/post\/letsencrypt-certificate.html\">Let&#8217;s Encrypt\uff0c\u514d\u8d39\u597d\u7528\u7684 HTTPS \u8bc1\u4e66<\/a>\u300d\u64cd\u4f5c\u4e86\u4e4b\u540e\u624d\u53d1\u73b0\u2014\u2014\u5b83\u5df2\u7ecf\u4e0d\u652f\u6301\u7ed9IP\u914d\u7f6eHTTPS\u8bc1\u4e66\u4e86\uff1b\u6ca1\u529e\u6cd5\uff0c\u53ea\u597d\u5148\u81ea\u7b7e\u53d1\u4e00\u4e2aHTTPS\u8bc1\u4e66\u505a\u6d4b\u8bd5\u3002<\/p>\n<p>\u4e4b\u524d\u505a\u8fc7\u51e0\u6b21\uff0c\u4f46\u6ca1\u6709\u8bb0\u5f55\u4e0b\u6765\uff0c\u6240\u4ee5\u73b0\u5728\u60f3\u914d\u7f6e\u53c8\u9700\u8981\u53bb\u7f51\u4e0a\u627e\uff0c\u8bd5\u4e86\u51e0\u4e2a\u4e4b\u540e\u7ec8\u4e8e\u627e\u5230\u4e00\u4e2a\u9760\u8c31\u7684\u6587\u7ae0\u300c<a href=\"http:\/\/blog.creke.net\/762.html\" target=\"_blank\">\u4e3anginx\u914d\u7f6ehttps\u5e76\u81ea\u7b7e\u540d\u8bc1\u4e66<\/a>\u300d\uff0c\u7167\u7740\u4e00\u6b65\u4e00\u6b65\u6267\u884c\u4e86\u4e00\u904d\uff0c\u6d4b\u8bd5OK\u3002\u6240\u4ee5\u5728\u6b64\u8bb0\u5f55\u4e00\u4e0b\uff0c\u65b9\u4fbf\u4ee5\u540e\u53c2\u8003\u3002<\/p>\n<h4>\u6b63\u6587\uff1a<\/h4>\n<h5>\u53c2\u8003\u89e3\u7b54\uff1a<\/h5>\n<h6>1\u3001\u5236\u4f5cCA\u8bc1\u4e66\uff1a<\/h6>\n<p>\u5236\u4f5cCA\u7684\u79c1\u94a5\uff08ca.key\uff09\uff1a<\/p>\n<pre class=\"\">openssl genrsa -des3 -out ca.key 2048<\/pre>\n<p>\u5236\u4f5c\u4e00\u4e2a\u4e0d\u9700\u8981\u5bc6\u7801\u7684CA\u79c1\u94a5\uff08\u7528\u5904\u53c2\u89c1\u300c\u7ed9\u535a\u5ba2\u6dfb\u52a0STARTSSL\u7684\u514d\u8d39SSL\u8bc1\u4e66\u300d\uff09\uff1a<\/p>\n<pre class=\"\">openssl rsa -in ca.key -out ca_decrypted.key<\/pre>\n<p>\u5236\u4f5cCA\u7684\u8bc1\u4e66\uff08ca.crt\uff09\uff1a<\/p>\n<pre class=\"\">openssl req -new -x509 -days 3650 -key ca.key -out ca.crt<\/pre>\n<h6>2\u3001\u5236\u4f5c\u7f51\u7ad9(\u6216IP)\u7684\u8bc1\u4e66\u5e76\u7528CA\u7b7e\u540d\u8ba4\u8bc1<\/h6>\n<p>\u5728\u8fd9\u91cc\uff0c\u5047\u8bbe\u7f51\u7ad9\u7684\u57df\u540d\u4e3a blog.ixyzero.com<\/p>\n<p>\u5236\u4f5c blog.ixyzero.com \u7684\u8bc1\u4e66\u79c1\u94a5\uff1a<\/p>\n<pre class=\"\">openssl genrsa -des3 -out blog.ixyzero.com.pem 1024<\/pre>\n<p>\u5236\u4f5c\u4e00\u4e2a\u4e0d\u9700\u8981\u5bc6\u7801\u7684 blog.ixyzero.com \u7684\u8bc1\u4e66\u79c1\u94a5\uff1a<\/p>\n<pre class=\"\">openssl rsa -in blog.ixyzero.com.pem -out blog.ixyzero.com.key<\/pre>\n<p>\u751f\u6210\u7b7e\u540d\u8bf7\u6c42\uff1a<\/p>\n<pre class=\"\">openssl req -new -key blog.ixyzero.com.pem -out blog.ixyzero.com.csr<\/pre>\n<p>\u5728common name\u4e2d\u586b\u5165\u7f51\u7ad9\u57df\u540d\uff0c\u5982 blog.ixyzero.com \u5373\u53ef\u751f\u6210\u8be5\u7ad9\u70b9\u7684\u8bc1\u4e66\uff0c\u540c\u65f6\u4e5f\u53ef\u4ee5\u4f7f\u7528\u6cdb\u57df\u540d\u5982 *.ixyzero.com \u6765\u751f\u6210\u6240\u6709\u4e8c\u7ea7\u57df\u540d\u53ef\u7528\u7684\u7f51\u7ad9\u8bc1\u4e66\u3002<\/p>\n<p>\u7528CA\u8fdb\u884c\u7b7e\u540d\uff1a<\/p>\n<pre class=\"\">openssl ca -policy policy_anything -days 3650 -cert ca.crt -keyfile ca.key -in blog.ixyzero.com.csr -out blog.ixyzero.com.crt<\/pre>\n<p>\u5176\u4e2d\uff0cpolicy\u53c2\u6570\u5141\u8bb8\u7b7e\u540d\u7684CA\u548c\u7f51\u7ad9\u8bc1\u4e66\u53ef\u4ee5\u6709\u4e0d\u540c\u7684\u56fd\u5bb6\u3001\u5730\u540d\u7b49\u4fe1\u606f\uff0cdays\u53c2\u6570\u5219\u662f\u7b7e\u540d\u65f6\u9650\u3002<\/p>\n<p>\u5982\u679c\u5728\u6267\u884c\u7b7e\u540d\u547d\u4ee4\u65f6\uff0c\u51fa\u73b0\u300c `unable to open &#8216;\/etc\/pki\/CA\/index.txt&#8217;` \u300d\u7684\u9519\u8bef\uff0c\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539 \/etc\/pki\/tls\/openssl.cnf \u4e2d \u300c`dir = .\/CA`\u300d\uff0c\u7136\u540e\uff1a<\/p>\n<pre class=\"\">mkdir -p CA\/newcerts\ntouch CA\/index.txt\ntouch CA\/serial\necho \"01\" &gt; CA\/serial<\/pre>\n<p>\u518d\u91cd\u65b0\u6267\u884c\u7b7e\u540d\u547d\u4ee4\u3002<\/p>\n<p>\u6700\u540e\uff0c\u628a ca.crt \u7684\u5185\u5bb9\u7c98\u8d34\u5230 blog.ixyzero.com.crt \u540e\u9762\u3002\u8fd9\u4e2a\u6bd4\u8f83\u91cd\u8981\uff01\u56e0\u4e3a\u4e0d\u8fd9\u6837\u505a\uff0c\u53ef\u80fd\u4f1a\u6709\u67d0\u4e9b\u6d4f\u89c8\u5668\u4e0d\u652f\u6301\u3002<\/p>\n<p>\u597d\u4e86\uff0c\u73b0\u5728 HTTPS \u9700\u8981\u7684\u7f51\u7ad9\u79c1\u94a5 blog.ixyzero.com.key \u548c \u7f51\u7ad9\u8bc1\u4e66 blog.ixyzero.com.crt \u90fd\u51c6\u5907\u5b8c\u6bd5\u4e86\u3002\u4e4b\u540e\u5c31\u53ef\u4ee5\u5f00\u59cb\u914d\u7f6eNginx\u4e86\u3002<\/p>\n<h5>\u53c2\u8003\u94fe\u63a5\uff1a<\/h5>\n<ul>\n<li><a href=\"http:\/\/blog.creke.net\/762.html\">\u4e3anginx\u914d\u7f6ehttps\u5e76\u81ea\u7b7e\u540d\u8bc1\u4e66<\/a><\/li>\n<\/ul>\n<p>=END=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>=Start= \u7f18\u7531\uff1a \u5728\u6d4b\u8bd5\u7ed9Nginx\u65b0\u589e\u6a21\u5757\u7684\u65f6\u5019\u60f3\u8bd5\u8bd5HTTPS\u7684\u914d\u7f6e\u65b9\u5f0f\uff0c\u4f46\u662f\u624b\u4e0a\u53c8\u6ca1\u6709\u591a\u7684\u57df\u540d\u4e86\uff0c [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,12],"tags":[701,277,702],"class_list":["post-3075","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-tools","tag-ca","tag-openssl","tag-702"],"views":6346,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/3075","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=3075"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/3075\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=3075"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=3075"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=3075"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}