{"id":48144,"date":"2023-05-06T21:59:38","date_gmt":"2023-05-06T13:59:38","guid":{"rendered":"http:\/\/lrxjmw.cn\/?p=48144"},"modified":"2023-05-06T21:59:38","modified_gmt":"2023-05-06T13:59:38","slug":"apache-openssl1","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/apache-openssl1.html","title":{"rendered":"Apache,dovecot\u4e0bOpenssl\u5e94\u7528\u4e00"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\n\u8fd9\u4e48\u957f\u65f6\u95f4\u4e4b\u540e\uff0c\u6211\u7684\u8bfb\u8005\u4eec\uff0c\u8fd9\u91cc\u662f\u6211\u7ed9\u4f60\u4eec\u627f\u8bfa\u7684\u5728 Apache \u4e2d\u4f7f\u7528 OpenSSL \u7684\u65b9\u6cd5\uff0c\u4e0b\u5468\u4f60\u4f1a\u770b\u5230\u5728 Dovecot \u4e2d\u4f7f\u7528 SSL\u3002 \u5728\u8fd9\u4e2a\u5206\u4e3a\u4e24\u90e8\u5206\u7684\u7cfb\u5217\u4e2d\uff0c\u6211\u4eec\u5c06\u5b66\u4e60\u5982\u4f55\u521b\u5efa\u81ea\u5df1\u7684 OpenSSL \u8bc1\u4e66\uff0c\u4ee5\u53ca\u5982\u4f55\u914d\u7f6e Apache \u548c Dovecot \u6765\u4f7f\u7528\u5b83\u4eec\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\"\"<\/p>\n

\u521b\u5efa\u4f60\u7684\u8bc1\u4e66<\/strong><\/div>\n

Debian\/Ubuntu\/Mint \u4f1a\u5728 \/etc\/ssl<\/span> \u4e2d\u5b58\u50a8\u79c1\u94a5\u548c\u8bc1\u4e66\u7684\u7b26\u53f7\u94fe\u63a5\u3002\u7cfb\u7edf\u81ea\u5e26\u7684\u8bc1\u4e66\u4fdd\u5b58\u5728\/usr\/share\/ca-certificates<\/span> \u4e2d\u3002\u4f60\u5b89\u88c5\u6216\u521b\u5efa\u7684\u8bc1\u4e66\u5728 \/usr\/local\/share\/ca-certificates\/<\/span> \u4e2d\u3002<\/p>\n

\u8fd9\u4e2a\u4f8b\u5b50\u662f\u5bf9 Debian \u800c\u8a00\u3002\u521b\u5efa\u79c1\u94a5\u548c\u516c\u7528\u8bc1\u4e66\uff0c\u5c06\u8bc1\u4e66\u8f6c\u6362\u4e3a\u6b63\u786e\u7684\u683c\u5f0f\uff0c\u5e76\u5c06\u5176\u7b26\u53f7\u94fe\u63a5\u5230\u6b63\u786e\u7684\u76ee\u5f55\uff1a<\/p>\n

$ sudo openssl req -x509 -days 365 -nodes -newkey rsa:2048 \\\r\n-keyout \/etc\/ssl\/private\/test-com.key -out \\\r\n\/usr\/local\/share\/ca-certificates\/test-com.crt\r\nGenerating a 2048 bit RSA private key\r\n.......+++\r\n......................................+++\r\nwriting new private key to '\/etc\/ssl\/private\/test-com.key'\r\n-----\r\nYou are about to be asked to enter information that will\r\nbe incorporated into your certificate request.\r\nWhat you are about to enter is what is called a Distinguished\r\nName or a DN. There are quite a few fields but you can leave some blank\r\nFor some fields there will be a default value,\r\nIf you enter '.', the field will be left blank.\r\n-----\r\nCountry Name (2 letter code) [AU]:US\r\nState or Province Name (full name) [Some-State]:WA\r\nLocality Name (eg, city) []:Seattle\r\nOrganization Name (eg, company) [Internet Widgits Pty Ltd]:Alrac Writing Sweatshop\r\nOrganizational Unit Name (eg, section) []:home dungeon\r\nCommon Name (e.g. server FQDN or YOUR name) []:www.test.com\r\nEmail Address []:admin@test.com\r\n$ sudo update-ca-certificates\r\nUpdating certificates in \/etc\/ssl\/certs...\r\n1 added, 0 removed; done.\r\nRunning hooks in \/etc\/ca-certificates\/update.d...\r\nAdding debian:test-com.pem\r\ndone.\r\ndone.<\/pre>\n

CentOS\/Fedora \u4f7f\u7528\u4e0d\u540c\u7684\u6587\u4ef6\u7ed3\u6784\uff0c\u5e76\u4e0d\u4f7f\u7528 update-ca-certificates<\/span>\uff0c\u4f7f\u7528\u8fd9\u4e2a\u547d\u4ee4\uff1a<\/p>\n

$ sudo openssl req -x509 -days 365 -nodes -newkey rsa:2048 \\\r\n-keyout \/etc\/httpd\/ssl\/test-com.key -out \\\r\n\/etc\/httpd\/ssl\/test-com.crt<\/pre>\n

\u6700\u91cd\u8981\u7684\u6761\u76ee\u662f Common Name<\/span>\uff0c\u5b83\u5fc5\u987b\u4e0e\u4f60\u7684\u5b8c\u5168\u9650\u5b9a\u57df\u540d\uff08FQDN\uff09\u5b8c\u5168\u5339\u914d\u3002\u6b64\u5916\u5176\u5b83\u4fe1\u606f\u90fd\u662f\u4efb\u610f\u7684\u3002-nodes<\/span> \u7528\u4e8e\u521b\u5efa\u4e00\u4e2a\u65e0\u5bc6\u7801\u7684\u8bc1\u4e66\uff0c\u8fd9\u662f Apache \u6240\u5fc5\u9700\u7684\u3002-days<\/span> \u7528\u4e8e\u5b9a\u4e49\u8fc7\u671f\u65e5\u671f\u3002\u66f4\u65b0\u8bc1\u4e66\u662f\u4e00\u4e2a\u9ebb\u70e6\u7684\u4e8b\u60c5\uff0c\u4f46\u8fd9\u6837\u5e94\u8be5\u80fd\u591f\u989d\u5916\u63d0\u4f9b\u4e00\u4e9b\u5b89\u5168\u4fdd\u969c\u3002<\/p>\n

>\u914d\u7f6e Apache<\/strong><\/div>\n

\u73b0\u5728\u914d\u7f6e Apache \u4ee5\u4f7f\u7528\u4f60\u7684\u65b0\u8bc1\u4e66\u3002\u5982\u679c\u4f60\u9075\u5faa\u7ed9\u521d\u5b66\u8005\u770b\u7684\u5728 Ubuntu Linux \u4e0a\u4f7f\u7528 Apache\uff1a\u7b2c 2 \u90e8\u5206\uff0c\u4f60\u6240\u8981\u505a\u7684\u5c31\u662f\u4fee\u6539\u865a\u62df\u4e3b\u673a\u914d\u7f6e\u4e2d\u7684 SSLCertificateFile<\/span> \u548c SSLCertificateKeyFile<\/span>\uff0c\u4ee5\u6307\u5411\u4f60\u7684\u65b0\u79c1\u94a5\u548c\u516c\u5171\u8bc1\u4e66\u3002\u6765\u81ea\u8be5\u6559\u7a0b\u4e2d\u7684 test.com<\/span> \u793a\u4f8b\u73b0\u5728\u770b\u8d77\u6765\u50cf\u8fd9\u6837\uff1a<\/p>\n

SSLCertificateFile \/etc\/ssl\/certs\/test-com.pem\r\nSSLCertificateKeyFile \/etc\/ssl\/private\/test-com.key<\/pre>\n

CentOS \u7528\u6237\uff0c\u8bf7\u53c2\u9605\u5728 CentOS wiki \u4e2d\u7684\u5728 CentOS \u4e0a\u8bbe\u7f6e SSL \u52a0\u5bc6\u7684 Web \u670d\u52a1\u5668\u4e00\u6587\u3002\u8fc7\u7a0b\u662f\u7c7b\u4f3c\u7684\uff0cwiki \u4f1a\u544a\u8bc9\u5982\u4f55\u5904\u7406 SELinux\u3002<\/p>\n

\u6d4b\u8bd5 Apache SSL<\/strong><\/div>\n

\u4e00\u4e2a\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u7528\u4f60\u7684\u7f51\u7edc\u6d4f\u89c8\u5668\u8bbf\u95ee https:\/\/yoursite.com\uff0c\u770b\u770b\u5b83\u662f\u5426\u53ef\u4ee5\u6b63\u5e38\u5de5\u4f5c\u3002\u5728\u7b2c\u4e00\u6b21\u8fd9\u6837\u505a\u65f6\uff0c\u4f60\u4f1a\u5728\u4f60\u8fc7\u5ea6\u4fdd\u62a4\u7684 web \u6d4f\u89c8\u5668\u4e2d\u770b\u5230\u53ef\u6015\u7684\u8b66\u544a\u8bf4\u7f51\u7ad9\u662f\u4e0d\u5b89\u5168\u7684\uff0c\u56e0\u4e3a\u5b83\u4f7f\u7528\u7684\u662f\u81ea\u7b7e\u540d\u8bc1\u4e66\u3002\u8bf7\u5ffd\u7565\u4f60\u8fd9\u4e2a\u654f\u611f\u7684\u6d4f\u89c8\u5668\uff0c\u5e76\u5355\u51fb\u5c4f\u5e55\u521b\u5efa\u6c38\u4e45\u6027\u4f8b\u5916\u3002 \u5982\u679c\u4f60\u9075\u5faa\u5728\u7ed9\u521d\u5b66\u8005\u770b\u7684\u5728 Ubuntu Linux \u4e0a\u4f7f\u7528 Apache\uff1a\u7b2c 2 \u90e8\u5206\u4e0a\u7684\u793a\u4f8b\u865a\u62df\u4e3b\u673a\u914d\u7f6e\uff0c\u90a3\u4e48\u5373\u4f7f\u4f60\u7684\u7f51\u7ad9\u8bbf\u95ee\u8005\u5c1d\u8bd5\u4f7f\u7528\u7eaf HTTP\uff0c\u4f60\u7684\u7f51\u7ad9\u7684\u6240\u6709\u6d41\u91cf\u90fd\u5c06\u5f3a\u5236\u901a\u8fc7 HTTPS\u3002<\/p>\n

\u4e00\u4e2a\u5f88\u597d\u6d4b\u8bd5\u65b9\u6cd5\u662f\u4f7f\u7528 OpenSSL\u3002\u662f\u7684\uff0c\u6709\u4e00\u4e2a\u6f02\u4eae\u7684\u547d\u4ee4\u6765\u6d4b\u8bd5\u8fd9\u4e9b\u4e1c\u897f\u3002\u8bd5\u4e0b\u8fd9\u4e2a\uff1a<\/p>\n

$ openssl s_client -connect www.test.com:443\r\nCONNECTED(00000003)\r\ndepth=0 C = US, ST = WA, L = Seattle, O = Alrac Writing Sweatshop,\r\nOU = home dungeon, CN = www.test.com, emailAddress = admin@test.com\r\nverify return:1\r\n---\r\nCertificate chain\r\n0 s:\/C=US\/ST=WA\/L=Seattle\/O=Alrac Writing Sweatshop\/OU=home\r\ndungeon\/CN=www.test.com\/emailAddress=admin@test.com\r\ni:\/C=US\/ST=WA\/L=Seattle\/O=Alrac Writing Sweatshop\/OU=home\r\ndungeon\/CN=www.test.com\/emailAddress=admin@test.com\r\n---\r\nServer certificate\r\n-----BEGIN CERTIFICATE-----\r\n[...]<\/pre>\n

\u8fd9\u91cc\u8f93\u51fa\u4e86\u5927\u91cf\u7684\u4fe1\u606f\u3002\u8fd9\u91cc\u6709\u5f88\u591a\u5173\u4e8e openssl s_client<\/span> \u7684\u6709\u8da3\u4fe1\u606f; \u73b0\u5728\u8db3\u591f\u6211\u4eec\u77e5\u9053\u6211\u4eec\u7684 web \u670d\u52a1\u5668\u662f\u5426\u4f7f\u7528\u4e86\u6b63\u786e\u7684 SSL \u8bc1\u4e66\u3002<\/p>\n

\u521b\u5efa\u4e00\u4e2a\u8bc1\u4e66\u7b7e\u540d\u8bf7\u6c42<\/strong><\/div>\n

\u5982\u679c\u4f60\u51b3\u5b9a\u4f7f\u7528\u7b2c\u4e09\u65b9\u8bc1\u4e66\u9881\u53d1\u673a\u6784\uff08CA\uff09\uff0c\u90a3\u4e48\u5c31\u5fc5\u987b\u521b\u5efa\u8bc1\u4e66\u7b7e\u540d\u8bf7\u6c42\uff08CSR\uff09\u3002\u4f60\u5c06\u5b83\u53d1\u9001\u7ed9\u4f60\u7684\u65b0 CA\uff0c\u4ed6\u4eec\u5c06\u7b7e\u7f72\u5e76\u5c06\u5176\u53d1\u9001\u7ed9\u60a8\u3002\u4ed6\u4eec\u53ef\u80fd\u5bf9\u521b\u5efa\u4f60\u7684 CSR \u6709\u81ea\u5df1\u7684\u8981\u6c42; \u8fd9\u662f\u5982\u4f55\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u79c1\u94a5\u548c CSR \u7684\u5178\u578b\u793a\u4f8b\uff1a<\/p>\n

$ openssl req -newkey rsa:2048 -nodes \\\r\n-keyout yourdomain.key -out yourdomain.csr<\/pre>\n

\u4f60\u4e5f\u53ef\u4ee5\u4ece\u4e00\u4e2a\u5df2\u7ecf\u5b58\u5728\u7684 key \u4e2d\u521b\u5efa\u4e00\u4e2a CSR\uff1a<\/p>\n

$ openssl req -key yourdomain.key \\\r\n-new -out domain.csr<\/pre>\n

\u4eca\u5929\u5c31\u662f\u8fd9\u6837\u4e86\u3002\u4e0b\u5468\u6211\u4eec\u5c06\u5b66\u4e60\u5982\u4f55\u6b63\u786e\u5730\u5728 Dovecot \u4e2d\u8bbe\u7f6e OpenSSL\u3002<\/p>\n


\n

via: https:\/\/www.linux.com\/learn\/sysadmin\/openssl-apache-and-dovecot<\/a><\/p>\n

\u4f5c\u8005\uff1aCARLA SCHRODER<\/a> \u8bd1\u8005\uff1ageekpi<\/a> \u6821\u5bf9\uff1awxy<\/a><\/p>\n

\u672c\u6587\u7531 LCTT<\/a> \u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd<\/a> \u8363\u8a89\u63a8\u51fa<\/p>\n

\n

\u539f\u6587\u6765\u81ea\uff1ahttps:\/\/linux.cn\/article-8167-1.html<\/a><\/p>\n

\u672c\u6587\u5730\u5740\uff1a http:\/\/lrxjmw.cn\/apache-openssl1.html<\/a>\u7f16\u8f91\uff1a\u674e\u5e05\uff0c\u5ba1\u6838\u5458\uff1a\u9004\u589e\u5b9d<\/span><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"

\u5bfc\u8bfb \u8fd9\u4e48\u957f\u65f6\u95f4\u4e4b\u540e\uff0c\u6211\u7684\u8bfb\u8005\u4eec\uff0c\u8fd9\u91cc\u662f\u6211\u7ed9\u4f60\u4eec\u627f\u8bfa\u7684\u5728 Apache \u4e2d\u4f7f\u7528 OpenSSL \u7684\u65b9\u6cd5\uff0c\u4e0b\u5468\u4f60 […]<\/p>\n","protected":false},"author":63,"featured_media":48230,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[21],"tags":[],"class_list":["post-48144","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/48144","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/63"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=48144"}],"version-history":[{"count":8,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/48144\/revisions"}],"predecessor-version":[{"id":271648,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/48144\/revisions\/271648"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/48230"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=48144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=48144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=48144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}