{"id":33532,"date":"2024-09-30T22:41:46","date_gmt":"2024-09-30T14:41:46","guid":{"rendered":"https:\/\/server.hk\/cnblog\/33532\/"},"modified":"2024-09-30T22:41:46","modified_gmt":"2024-09-30T14:41:46","slug":"apache%e5%ae%89%e5%85%a8%e7%ad%96%e7%95%a5%ef%bc%9a%e4%bd%bf%e7%94%a8mod_ssl%e6%8f%90%e4%be%9bocsp-stapling","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/33532\/","title":{"rendered":"Apache\u5b89\u5168\u7b56\u7565\uff1a\u4f7f\u7528mod_ssl\u63d0\u4f9bOCSP stapling"},"content":{"rendered":"<h1 id=\"apache%e5%ae%89%e5%85%a8%e7%ad%96%e7%95%a5%ef%bc%9a%e4%bd%bf%e7%94%a8mod_ssl%e6%8f%90%e4%be%9bocsp-stapling-tlrnAyzofa\">Apache\u5b89\u5168\u7b56\u7565\uff1a\u4f7f\u7528mod_ssl\u63d0\u4f9bOCSP stapling<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u7db2\u7d61\u74b0\u5883\u4e2d\uff0c\u7db2\u7ad9\u5b89\u5168\u6027\u8b8a\u5f97\u8d8a\u4f86\u8d8a\u91cd\u8981\u3002\u96a8\u8457\u6578\u64da\u6d29\u9732\u548c\u7db2\u7d61\u653b\u64ca\u4e8b\u4ef6\u7684\u983b\u7e41\u767c\u751f\uff0c\u7db2\u7ad9\u7ba1\u7406\u8005\u5fc5\u9808\u63a1\u53d6\u6709\u6548\u7684\u63aa\u65bd\u4f86\u4fdd\u8b77\u7528\u6236\u7684\u6578\u64da\u3002Apache\u4f5c\u70ba\u4e00\u500b\u5ee3\u6cdb\u4f7f\u7528\u7684\u7db2\u9801\u4f3a\u670d\u5668\uff0c\u63d0\u4f9b\u4e86\u591a\u7a2e\u5b89\u5168\u529f\u80fd\uff0c\u5176\u4e2d\u4e4b\u4e00\u5c31\u662f\u4f7f\u7528mod_ssl\u6a21\u7d44\u4f86\u5be6\u73feOCSP stapling\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%afocsp-stapling%ef%bc%9f-tlrnAyzofa\">\u4ec0\u9ebc\u662fOCSP Stapling\uff1f<\/h2>\n<p>OCSP\uff08Online Certificate Status Protocol\uff09\u662f\u4e00\u7a2e\u7528\u65bc\u6aa2\u67e5\u6578\u5b57\u8b49\u66f8\u6709\u6548\u6027\u7684\u5354\u8b70\u3002\u50b3\u7d71\u4e0a\uff0c\u7576\u7528\u6236\u8a2a\u554f\u4e00\u500b\u7db2\u7ad9\u6642\uff0c\u700f\u89bd\u5668\u6703\u5411\u8b49\u66f8\u9812\u767c\u6a5f\u69cb\uff08CA\uff09\u767c\u9001\u8acb\u6c42\uff0c\u4ee5\u78ba\u8a8d\u8a72\u8b49\u66f8\u662f\u5426\u4ecd\u7136\u6709\u6548\u3002\u9019\u7a2e\u65b9\u6cd5\u96d6\u7136\u6709\u6548\uff0c\u4f46\u6703\u589e\u52a0\u5ef6\u9072\uff0c\u4e26\u4e14\u53ef\u80fd\u6703\u5c0e\u81f4\u96b1\u79c1\u554f\u984c\u3002<\/p>\n<p>OCSP stapling\u5247\u662f\u4e00\u7a2e\u6539\u9032\u7684\u65b9\u6848\u3002\u5b83\u5141\u8a31\u4f3a\u670d\u5668\u5728TLS\u63e1\u624b\u904e\u7a0b\u4e2d\u5c07OCSP\u97ff\u61c9\u201c\u7c98\u8cbc\u201d\u5230\u8b49\u66f8\u4e2d\uff0c\u9019\u6a23\u7528\u6236\u7684\u700f\u89bd\u5668\u5c31\u4e0d\u9700\u8981\u76f4\u63a5\u67e5\u8a62CA\u3002\u9019\u4e0d\u50c5\u63d0\u9ad8\u4e86\u6027\u80fd\uff0c\u9084\u589e\u5f37\u4e86\u96b1\u79c1\u4fdd\u8b77\u3002<\/p>\n<h2 id=\"%e7%82%ba%e4%bb%80%e9%ba%bc%e4%bd%bf%e7%94%a8ocsp-stapling%ef%bc%9f-tlrnAyzofa\">\u70ba\u4ec0\u9ebc\u4f7f\u7528OCSP Stapling\uff1f<\/h2>\n<ul>\n<li><strong>\u6027\u80fd\u63d0\u5347\uff1a<\/strong>\u7531\u65bc\u6e1b\u5c11\u4e86\u5c0dCA\u7684\u8acb\u6c42\uff0c\u7db2\u7ad9\u7684\u52a0\u8f09\u901f\u5ea6\u53ef\u4ee5\u986f\u8457\u63d0\u9ad8\u3002<\/li>\n<li><strong>\u96b1\u79c1\u4fdd\u8b77\uff1a<\/strong>\u7528\u6236\u7684\u8b49\u66f8\u72c0\u614b\u67e5\u8a62\u4e0d\u518d\u66b4\u9732\u7d66CA\uff0c\u5f9e\u800c\u4fdd\u8b77\u4e86\u7528\u6236\u7684\u96b1\u79c1\u3002<\/li>\n<li><strong>\u53ef\u9760\u6027\uff1a<\/strong>\u5982\u679cCA\u7684\u670d\u52d9\u5668\u51fa\u73fe\u6545\u969c\uff0c\u4f7f\u7528OCSP stapling\u7684\u7db2\u7ad9\u4ecd\u7136\u53ef\u4ee5\u6b63\u5e38\u904b\u884c\uff0c\u56e0\u70ba\u4f3a\u670d\u5668\u5df2\u7d93\u7de9\u5b58\u4e86OCSP\u97ff\u61c9\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e5%9c%a8apache%e4%b8%ad%e5%95%9f%e7%94%a8ocsp-stapling-tlrnAyzofa\">\u5982\u4f55\u5728Apache\u4e2d\u555f\u7528OCSP Stapling<\/h2>\n<p>\u8981\u5728Apache\u4e2d\u555f\u7528OCSP stapling\uff0c\u60a8\u9700\u8981\u78ba\u4fdd\u5df2\u5b89\u88ddmod_ssl\u6a21\u7d44\u3002\u4ee5\u4e0b\u662f\u555f\u7528OCSP stapling\u7684\u6b65\u9a5f\uff1a<\/p>\n<h3 id=\"%e6%ad%a5%e9%a9%9f1%ef%bc%9a%e6%aa%a2%e6%9f%a5mod_ssl%e6%a8%a1%e7%b5%84-tlrnAyzofa\">\u6b65\u9a5f1\uff1a\u6aa2\u67e5mod_ssl\u6a21\u7d44<\/h3>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u78ba\u4fddApache\u5df2\u7d93\u555f\u7528\u4e86mod_ssl\u6a21\u7d44\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u6aa2\u67e5\uff1a<\/p>\n<pre><code>apachectl -M | grep ssl<\/code><\/pre>\n<p>\u5982\u679c\u672a\u555f\u7528\uff0c\u60a8\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u547d\u4ee4\u4f86\u555f\u7528\uff1a<\/p>\n<pre><code>sudo a2enmod ssl<\/code><\/pre>\n<h3 id=\"%e6%ad%a5%e9%a9%9f2%ef%bc%9a%e9%85%8d%e7%bd%aeocsp-stapling-tlrnAyzofa\">\u6b65\u9a5f2\uff1a\u914d\u7f6eOCSP Stapling<\/h3>\n<p>\u63a5\u4e0b\u4f86\uff0c\u60a8\u9700\u8981\u7de8\u8f2fApache\u7684\u914d\u7f6e\u6587\u4ef6\uff08\u901a\u5e38\u4f4d\u65bc\/etc\/httpd\/conf\/httpd.conf\u6216\/etc\/apache2\/sites-available\/default-ssl.conf\uff09\u3002\u5728\u76f8\u61c9\u7684\u865b\u64ec\u4e3b\u6a5f\u914d\u7f6e\u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u6307\u4ee4\uff1a<\/p>\n<pre><code>\nSSLUseStapling On\nSSLStaplingCache \"shmcb:\/var\/run\/ocsp-stapling-cache(128000)\"\n<\/code><\/pre>\n<p>\u9019\u88e1\uff0cSSLUseStapling\u6307\u4ee4\u555f\u7528OCSP stapling\uff0c\u800cSSLStaplingCache\u5247\u6307\u5b9a\u4e86\u7de9\u5b58\u7684\u5b58\u5132\u4f4d\u7f6e\u548c\u5927\u5c0f\u3002<\/p>\n<h3 id=\"%e6%ad%a5%e9%a9%9f3%ef%bc%9a%e9%87%8d%e5%95%9fapache%e6%9c%8d%e5%8b%99-tlrnAyzofa\">\u6b65\u9a5f3\uff1a\u91cd\u555fApache\u670d\u52d9<\/h3>\n<p>\u5b8c\u6210\u914d\u7f6e\u5f8c\uff0c\u60a8\u9700\u8981\u91cd\u555fApache\u670d\u52d9\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\uff1a<\/p>\n<pre><code>sudo systemctl restart apache2<\/code><\/pre>\n<h2 id=\"%e6%b8%ac%e8%a9%a6ocsp-stapling-tlrnAyzofa\">\u6e2c\u8a66OCSP Stapling<\/h2>\n<p>\u8981\u78ba\u8a8dOCSP stapling\u662f\u5426\u6b63\u5e38\u5de5\u4f5c\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre><code>openssl s_client -connect yourdomain.com:443 -status<\/code><\/pre>\n<p>\u5728\u8f38\u51fa\u7684\u7d50\u679c\u4e2d\uff0c\u60a8\u61c9\u8a72\u80fd\u770b\u5230\u201cOCSP Response\u201d\u90e8\u5206\uff0c\u9019\u8868\u793aOCSP stapling\u5df2\u6210\u529f\u555f\u7528\u3002<\/p>\n<h2 id=\"%e7%b5%90%e8%ab%96-tlrnAyzofa\">\u7d50\u8ad6<\/h2>\n<p>\u4f7f\u7528OCSP stapling\u53ef\u4ee5\u986f\u8457\u63d0\u9ad8\u7db2\u7ad9\u7684\u6027\u80fd\u548c\u5b89\u5168\u6027\u3002\u901a\u904e\u7c21\u55ae\u7684\u914d\u7f6e\uff0cApache\u4f3a\u670d\u5668\u53ef\u4ee5\u6709\u6548\u5730\u4fdd\u8b77\u7528\u6236\u7684\u6578\u64da\uff0c\u4e26\u63d0\u5347\u7528\u6236\u9ad4\u9a57\u3002\u96a8\u8457\u7db2\u7d61\u5b89\u5168\u5a01\u8105\u7684\u589e\u52a0\uff0c\u7db2\u7ad9\u7ba1\u7406\u8005\u61c9\u8a72\u8003\u616e\u5be6\u65bd\u9019\u4e00\u7b56\u7565\uff0c\u4ee5\u78ba\u4fdd\u5176\u7db2\u7ad9\u7684\u5b89\u5168\u6027\u548c\u53ef\u9760\u6027\u3002<\/p>\n<p>\u5982\u9700\u4e86\u89e3\u66f4\u591a\u6709\u95dc<em><a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a><\/em>\u548c<em><a href=\"https:\/\/server.hk\">\u4f3a\u670d\u5668<\/a><\/em>\u7684\u8cc7\u8a0a\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to enhance Apache security with mod_ssl by implementing OCSP stapling for improved SSL certificate validation and performance.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-33532","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/33532","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=33532"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/33532\/revisions"}],"predecessor-version":[{"id":33533,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/33532\/revisions\/33533"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=33532"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=33532"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=33532"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}