{"id":25373,"date":"2024-05-11T17:00:18","date_gmt":"2024-05-11T09:00:18","guid":{"rendered":"https:\/\/www.zhidianwl.net\/zhidianwl\/?p=25373"},"modified":"2024-05-11T17:00:18","modified_gmt":"2024-05-11T09:00:18","slug":"ssl%e8%af%81%e4%b9%a6%e7%94%b3%e8%af%b7%e6%ba%90%e7%a0%81%e4%bd%9c%e7%94%a8%e4%bb%8b%e7%bb%8d","status":"publish","type":"post","link":"https:\/\/www.zhidianwl.net\/zhidianwl\/2024\/05\/11\/ssl%e8%af%81%e4%b9%a6%e7%94%b3%e8%af%b7%e6%ba%90%e7%a0%81%e4%bd%9c%e7%94%a8%e4%bb%8b%e7%bb%8d\/","title":{"rendered":"ssl\u8bc1\u4e66\u7533\u8bf7\u6e90\u7801\u4f5c\u7528\u4ecb\u7ecd"},"content":{"rendered":"

SSL\u8bc1\u4e66\u662f\u4e00\u79cd\u6570\u5b57\u8bc1\u4e66\uff0c\u7528\u4e8e\u786e\u4fdd\u5728\u4e92\u8054\u7f51\u4e0a\u8fdb\u884c\u7684\u6570\u636e\u4f20\u8f93\u5b89\u5168\u3002\u5b83\u662f\u7531\u4e00\u5bb6\u53d7\u4fe1\u4efb\u7684\u7b2c\u4e09\u65b9\u673a\u6784\u7b7e\u53d1\u7684\uff0c\u8bc1\u660e\u4e86\u7f51\u7ad9\u7684\u8eab\u4efd\u548c\u5b89\u5168\u6027\u3002\u4e0b\u9762\u6211\u4eec\u6765\u8be6\u7ec6\u4ecb\u7ecd\u4e00\u4e0bSSL\u8bc1\u4e66\u7684\u7533\u8bf7\u6e90\u7801\u3002<\/p>\n

\u4e00\u3001SSL\u8bc1\u4e66\u7684\u539f\u7406<\/p>\n

SSL\u8bc1\u4e66\u662f\u57fa\u4e8e\u516c\u94a5\u52a0\u5bc6\u6280\u672f\u7684\u5b89\u5168\u534f\u8bae\uff0c\u4e3b\u8981\u7528\u4e8e\u5728\u4e92\u8054\u7f51\u4e0a\u5efa\u7acb\u5b89\u5168\u901a\u4fe1\u7ebf\u8def\u3002SSL\u8bc1\u4e66\u7684\u539f\u7406\u662f\u5229\u7528\u975e\u5bf9\u79f0\u52a0\u5bc6\u7b97\u6cd5\uff0c\u901a\u8fc7\u516c\u94a5\u52a0\u5bc6\u548c\u79c1\u94a5\u89e3\u5bc6\u6765\u786e\u4fdd\u6570\u636e\u7684\u5b89\u5168\u6027\u3002\u5177\u4f53\u6765\u8bf4\uff0cSSL\u8bc1\u4e66\u7684\u7533\u8bf7\u8fc7\u7a0b\u5982\u4e0b\uff1a<\/p>\n

1. \u7533\u8bf7\u8005\u5411\u8bc1\u4e66\u9881\u53d1\u673a\u6784\u63d0\u4ea4\u8bc1\u4e66\u8bf7\u6c42<\/p>\n

2. \u8bc1\u4e66\u9881\u53d1\u673a\u6784\u9a8c\u8bc1\u7533\u8bf7\u8005\u7684\u8eab\u4efd\u548c\u7f51\u7ad9\u4fe1\u606f<\/p>\n

3. \u8bc1\u4e66\u9881\u53d1\u673a\u6784\u751f\u6210\u8bc1\u4e66\u5e76\u7528\u79c1\u94a5\u52a0\u5bc6<\/p>\n

4. \u8bc1\u4e66\u9881\u53d1\u673a\u6784\u5c06\u8bc1\u4e66\u53d1\u9001\u7ed9\u7533\u8bf7\u8005<\/p>\n

5. \u7528\u6237\u901a\u8fc7\u6d4f\u89c8\u5668\u8bbf\u95ee\u7f51\u7ad9\u65f6\uff0c\u7f51\u7ad9\u5c06\u8bc1\u4e66\u53d1\u9001\u7ed9\u7528\u6237<\/p>\n

6. \u7528\u6237\u6d4f\u89c8\u5668\u4f7f\u7528\u8bc1\u4e66\u9881\u53d1\u673a\u6784\u7684\u516c\u94a5\u89e3\u5bc6\u8bc1\u4e66<\/p>\n

7. \u7528\u6237\u6d4f\u89c8\u5668\u9a8c\u8bc1\u8bc1\u4e66\u7684\u6709\u6548\u6027\uff0c\u786e\u4fdd\u7f51\u7ad9ssl\u8bc1\u4e66\u7b7e\u540d\u7533\u8bf7<\/a>\u7684\u8eab\u4efd\u548c\u5b89\u5168\u6027<\/p>\n

\u4e8c\u3001SSL\u8bc1\u4e66\u7684\u7533\u8bf7\u6e90\u7801<\/p>\n

SSL\u8bc1\u4e66\u7684\u7533\u8bf7\u6e90\u7801\u4e3b\u8981\u5305\u62ec\u4ee5\u4e0b\u51e0\u4e2a\u90e8\u5206\uff1a<\/p>\n

1. \u8bc1\u4e66\u8bf7\u6c42\u751f\u6210<\/p>\n

\u5728\u7533\u8bf7SSL\u8bc1\u4e66\u4e4b\u524d\uff0c\u9700\u8981\u5148\u751f\u6210\u8bc1\u4e66\u8bf7\u6c42\u6587\u4ef6\u3002\u8bc1\u4e66\u8bf7\u6c42\u6587\u4ef6\u5305\u542b\u4e86\u7533\u8bf7\u8005\u7684\u4e2a\u4eba\u4fe1\u606f\u548c\u7f51\u7ad9\u4fe1\u606f\uff0c\u7528\u4e8e\u8bc1\u4e66\u9881\u53d1\u673a\u6784\u9a8c\u8bc1\u7533\u8bf7\u8005\u7684\u8eab\u4efd\u548c\u7f51\u7ad9\u4fe1\u606f\u3002\u8bc1\u4e66\u8bf7\u6c42\u6587\u4ef6\u7684\u751f\u6210\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n

“`<\/p>\n

$countryName = “CN”;<\/p>\n

$stateOrProvinceName = “Beijing”;<\/p>\n

$localityName = “Beijing”;<\/p>\n

$organizationName = “Example, Inc.”;<\/p>\n

$organizationalUnitName = “IT Department”;<\/p>\n

$commonName = “www.example.com”;<\/p>\n

$emailAddress = “webmaster@example.com”;<\/p>\n

$dn = array(<\/p>\n

“countryName” => $countryName,<\/p>\n

“stateOrProvinceName” => $stateOrProvinceName,<\/p>\n

“localityName” => $localityName,<\/p>\n

“organizationName” => $organizationName,<\/p>\n

“organizationalUnitName” => $organizationalUnitName,<\/p>\n

“commonName” => $commonName,<\/p>\n

“emailAddress” => $emailAddress<\/p>\n

);<\/p>\n

$privateKey = openssl_pkey_new();<\/p>\n

$csr = openssl_csr_new($dn, $privateKey);<\/p>\n

openssl_csr_export($csr, $csrout);<\/p>\n

openssl_pkey_export($privateKey, $privkey);<\/p>\n

file_put_contents(“example_com.csr”, $csrout);<\/p>\n

file_put_contents(“example_com.key”, $privkey);<\/p>\n

“`<\/p>\n

2. \u8bc1\u4e66\u8bf7\u6c42\u63d0\u4ea4<\/p>\n

\u8bc1\u4e66\u8bf7\u6c42\u6587\u4ef6\u751f\u6210\u5b8c\u6210\u540e\uff0c\u9700\u8981\u5c06\u5176\u63d0\u4ea4\u7ed9\u8bc1\u4e66\u9881\u53d1\u673a\u6784\u8fdb\u884c\u9a8c\u8bc1\u548c\u7b7e\u53d1\u3002\u8bc1\u4e66\u8bf7\u6c42\u63d0\u4ea4\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n

“`<\/p>\n

$csr = file_get_contents(“example_com.csr”);<\/p>\n

$ch = curl_init();<\/p>\n

curl_setopt($ch, CURLOPT_URL, “https:\/\/example.com\/certificate”);<\/p>\n

curl_setopt($ch, CURLOPT_POST, 1);<\/p>\n

curl_setopt($ch, CURLOPT_POSTFIELDS, array(<\/p>\n

“csr” => $csr<\/p>\n

));<\/p>\n

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);<\/p>\n

$re<\/p>\n

<\/figure>\n<\/p>\n

sult = curl_exec($ch);<\/p>\n

curl_close($ch);<\/p>\n

echo $result;<\/p>\n

“`<\/p>\n

3. \u8bc1\u4e66\u5b89\u88c5<\/p>\n

\u8bc1\u4e66\u9881\u53d1\u673a\u6784\u7b7e\u53d1\u8bc1\u4e66\u540e\uff0c\u9700\u8981\u5c06\u8bc1\u4e66\u5b89\u88c5\u5230\u670d\u52a1\u5668\u4e0a\u3002\u8bc1\u4e66\u5b89\u88c5\u5305\u62ec\u5c06\u8bc1\u4e66\u6587\u4ef6\u548c\u79c1\u94a5\u6587\u4ef6\u4e0a\u4f20\u5230\u670d\u52a1\u5668\uff0c\u5e76\u914d\u7f6e\u670d\u52a1\u5668\u8f6f\u4ef6\uff08\u5982Apache\u3001Nginx\u7b49\uff09\u4ee5\u4f7f\u7528SSL\u8bc1\u4e66\u3002\u8bc1\u4e66\u5b89\u88c5\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n

“`<\/p>\n

$certificate = file_get_contents(“example_com.crt”);<\/p>\n

$privateKey = file_get_contents(“example_com.key”);<\/p>\n

\/\/ Apache\u914d\u7f6e<\/p>\n

file_put_contents(“\/etc\/apache2\/ssl\/example_com.crt”, $certificate);<\/p>\n

file_put_contents(“\/etc\/apache2\/ssl\/example_com.key”, $privateKey);<\/p>\n

\/\/ Nginx\u914d\u7f6e<\/p>\n

file_put_contents(“\/etc\/nginx\/ssl\/example_com.crt”, $certificate);<\/p>\n

file_put_contents(“\/etc\/nginx\/ssl\/example_com.key”, $privateKey);<\/p>\n

“`<\/p>\n

\u4ee5\u4e0a\u662fSSL\u8bc1\u4e66\u7684\u7533\u8bf7\u6e90\u7801\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5b9e\u9645\u7533\u8bf7\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u4f1a\u6709\u4e00\u4e9b\u7ec6\u8282\u95ee\u9898\u9700\u8981\u6ce8\u610f\uff0c\u5982\u8bc1\u4e66\u9881\u53d1\u673a\u6784\u7684\u9009\u62e9\u3001\u8bc1\u4e66\u7c7b\u578b\u7684\u9009\u62e9\u7b49\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"

SSL\u8bc1\u4e66\u662f\u4e00\u79cd\u6570\u5b57\u8bc1\u4e66\uff0c\u7528\u4e8e\u786e\u4fdd\u5728\u4e92\u8054\u7f51\u4e0a\u8fdb\u884c\u7684\u6570\u636e\u4f20\u8f93\u5b89\u5168\u3002\u5b83\u662f\u7531\u4e00\u5bb6\u53d7\u4fe1\u4efb\u7684\u7b2c\u4e09\u65b9\u673a\u6784\u7b7e\u53d1\u7684\uff0c\u8bc1\u660e\u4e86\u7f51\u7ad9\u7684\u8eab\u4efd\u548c\u5b89\u5168\u6027\u3002\u4e0b\u9762\u6211\u4eec\u6765\u8be6\u7ec6\u4ecb\u7ecd\u4e00\u4e0bSSL\u8bc1\u4e66\u7684\u7533\u8bf7\u6e90\u7801\u3002\u4e00\u3001SSL\u8bc1\u4e66\u7684\u539f\u7406SSL\u8bc1<\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[24797,24798,528,498,138],"topic":[],"class_list":["post-25373","post","type-post","status-publish","format-standard","hentry","category-sslzhengshu","tag-https-","tag-javahttps","tag-528","tag-498","tag-138"],"_links":{"self":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/25373","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/comments?post=25373"}],"version-history":[{"count":1,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/25373\/revisions"}],"predecessor-version":[{"id":25452,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/posts\/25373\/revisions\/25452"}],"wp:attachment":[{"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/media?parent=25373"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/categories?post=25373"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/tags?post=25373"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.zhidianwl.net\/zhidianwl\/wp-json\/wp\/v2\/topic?post=25373"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}