﻿{"id":2107,"date":"2020-08-19T14:02:55","date_gmt":"2020-08-19T06:02:55","guid":{"rendered":"http:\/\/nick.txtcc.com\/?p=2107"},"modified":"2020-08-19T16:56:34","modified_gmt":"2020-08-19T08:56:34","slug":"%e8%a7%a3%e5%86%b3python3-7%e4%b8%8eopenssl%e7%9a%84%e4%bd%8e%e7%89%88%e6%9c%ac%e4%b8%8d%e5%85%bc%e5%ae%b9%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/nick.txtcc.com\/index.php\/linux\/2107","title":{"rendered":"\u89e3\u51b3python3.7\u4e0eopenssl\u7684\u4f4e\u7248\u672c\u4e0d\u517c\u5bb9\u7684\u95ee\u9898"},"content":{"rendered":"<p>\u5b89\u88c5\u4e86Python3.7\u4e4b\u540e\uff0c\u9047\u5230\u7684\u4e00\u4e2a\u5f88\u9ebb\u70e6\u7684\u5751\u5c31\u662f\u4e0e\u7cfb\u7edf\u81ea\u5e26\u7684ssl\u7248\u672c\u4e0d\u517c\u5bb9\uff0c\u00a0Python3.7\u9700\u8981\u7684openssl\u7684\u7248\u672c\u4e3a<code>1.0.2<\/code>\u6216\u8005<code>1.1.x\uff0c\u8fd9\u4e2arequirements\u5728config Python3.7\u7684\u65f6\u5019\u4f7f\u7528&ldquo;<\/code>&#8211;with-ssl<code>&rdquo;\u9009\u9879\u4f1a\u62a5\u51fa\u3002<\/code><\/p>\n<ol class=\"hljs-ln\">\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\">Could not build the ssl module!<\/div>\n<\/div><\/li>\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\">Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_PARAM_set1_host().<\/div>\n<\/div><\/li>\n<\/ol>\n<p><code>Linux\u7cfb\u7edf\u9ed8\u8ba4\u7684openssl\u7248\u672c\u901a\u5e38\u662f\uff1aOpenSSL 1.0.1\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4\u67e5\u8be2\u7cfb\u7edf\u7684openssl\u7248\u672c\uff1a<\/code><\/p>\n<pre name=\"code\" class=\"has\"><code class=\"language-bash hljs\">openssl version<\/code><\/pre>\n<p><code>&lt;img class=&quot;has&quot; src=&quot;http:\/\/nick.txtcc.com\/wp-content\/uploads\/remote_image\/2020\/08\/060255PN7.png&quot; alt=&quot;&quot; width=&quot;838&quot; height=&quot;76&quot; \/&gt;<\/code><\/p>\n<p>\u5f53\u524d\u7248\u672c\u4f4e\u4e8ePython3.7\u7684\u9700\u6c42\uff0c\u4f1a\u5bfc\u81f4\u4e00\u4e9b\u8fd0\u884c\u9519\u8bef\uff0c\u6bd4\u5982pip3 install\u547d\u4ee4\u7684\u5931\u8d25\uff0c\u6545\u9700\u8981\u8fdb\u884c<code>openssl\u7248\u672c\u5347\u7ea7\u3002<\/code><\/p>\n<p><code>&lt;img class=&quot;has&quot; src=&quot;http:\/\/nick.txtcc.com\/wp-content\/uploads\/remote_image\/2020\/08\/060255mMn.jpg&quot; alt=&quot;&quot; \/&gt;<\/code><\/p>\n<p>\uff081\uff09\u4e0b\u8f7d\u8f83\u9ad8\u7248\u672c\u7684openssl<\/p>\n<pre name=\"code\" class=\"has\"><\/pre>\n<p><a href=\"https:\/\/www.openssl.org\/source\/openssl-1.1.1g.tar.gz\">https:\/\/www.openssl.org\/source\/openssl-1.1.1g.tar.gz<\/a> \uff082\uff09\u89e3\u538b\u5b89\u88c5\u5305 <\/p>\n<pre name=\"code\" class=\"has\"><code class=\"hljs apache\">&lt;span class=&quot;hljs-attribute&quot;&gt;tar&lt;\/span&gt; -xvzf openssl-1.1.1g.tar.gz<\/code><\/pre>\n<p>\uff083\uff09\u7f16\u8bd1\u5b89\u88c5<\/p>\n<ol class=\"hljs-ln\">\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\"><span class=\"hljs-built_in\">cd\u00a0<\/span>openssl-1.1.1g<\/div>\n<\/div><\/li>\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\">.\/config &#8211;prefix=\/usr\/<span class=\"hljs-built_in\">local<\/span>\/openssl no-zlib <span class=\"hljs-comment\"># \u65b0\u7248openssl\u5c06\u5b89\u88c5\u5728\/usr\/local\/openssl\u76ee\u5f55\u4e0b<\/span><\/div>\n<\/div><\/li>\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\">make<\/div>\n<\/div><\/li>\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\">make install<\/div>\n<\/div><\/li>\n<\/ol>\n<p>\u8fd9\u6837\u7684\u8bdd\uff0c\u65b0\u7248\u672c\u7684openssl\u5df2\u7ecf\u5b89\u88c5\u5b8c\u6bd5\uff0c\u4f46\u662f\u9700\u8981\u8fdb\u884c\u4e00\u4e9b\u73af\u5883\u914d\u7f6e\u624d\u80fd\u591f\u7ee7\u7eed\u4f7f\u7528\u3002<\/p>\n<p>\u6765\u5230\/usr\/bin\u76ee\u5f55\u4e0b\uff0c\u53ef\u4ee5\u53d1\u73b0\u5df2\u7ecf\u6709\u4e00\u4e2aopenssl\u53ef\u6267\u884c\u6587\u4ef6\uff0c\u8fd9\u4e2a\u5c31\u662f\u7cfb\u7edf\u81ea\u5e26\u7684\u4f4e\u7248\u672c\uff0c\u8fd9\u91cc\u6211\u4eec\u5bf9\u5b83\u8fdb\u884c\u4e00\u4e2a\u5907\u4efd\u3002<\/p>\n<p>\uff084\uff09\u5907\u4efd\u539fopenssl\u914d\u7f6e<\/p>\n<p>\u5907\u4efd\u662f\u4e2a\u597d\u7684\u4e60\u60ef\uff0c\u81f3\u5c11\u5728\u5b89\u88c5\u65b0\u7248\u672c\u51fa\u9519\u7684\u65f6\u5019\u53ef\u4ee5\u56de\u6eda\u65e7\u7248\u672c\u7ee7\u7eed\u4f7f\u7528\u3002<\/p>\n<ol class=\"hljs-ln\">\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\">mv \/usr\/bin\/openssl \/usr\/bin\/openssl_bak <span class=\"hljs-comment\"># backup<\/span><\/div>\n<\/div><\/li>\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\">mv \/usr\/include\/openssl\/ \/usr\/include\/openssl_bak<\/div>\n<\/div><\/li>\n<\/ol>\n<p>\uff085\uff09\u5907\u4efd\u597d\u4e4b\u540e\u5c31\u53ef\u4ee5\u4e3a\u65b0\u7248openssl\u914d\u7f6e\u8f6f\u8fde\u63a5\u4e86<\/p>\n<ol class=\"hljs-ln\">\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\"><span class=\"hljs-comment\"># \u5c06\u5b89\u88c5\u597d\u7684openssl\u7684openssl\u547d\u4ee4\u8f6f\u8fde\u5230\/usr\/bin\/openssl<\/span><\/div>\n<\/div><\/li>\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\">ln -s \/usr\/<span class=\"hljs-built_in\">local<\/span>\/openssl\/include\/openssl \/usr\/include\/openssl<\/div>\n<\/div><\/li>\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\"><\/div><\/li>\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\"><span class=\"hljs-comment\"># \u8f6f\u94fe\u5230\u5347\u7ea7\u540e\u7684libssl.so<\/span><\/div>\n<\/div><\/li>\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\">ln -s \/usr\/<span class=\"hljs-built_in\">local<\/span>\/openssl\/lib\/libssl.so.1.1 \/usr\/<span class=\"hljs-built_in\">local<\/span>\/lib64\/libssl.so<\/div>\n<\/div><\/li>\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\"><\/div><\/li>\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\"><span class=\"hljs-comment\"># \u5c06\u5b89\u88c5\u597d\u7684openssl\u547d\u4ee4\u8f6f\u8fde\u5230\/usr\/bin\/openssl<\/span><\/div>\n<\/div><\/li>\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\">ln -s \/usr\/<span class=\"hljs-built_in\">local<\/span>\/openssl\/bin\/openssl \/usr\/bin\/openssl<\/div>\n<\/div><\/li>\n<\/ol>\n<p>\uff086\uff09\u6700\u540e\u518d\u4fee\u6539\u4e0b\u7cfb\u7edf\u914d\u7f6e\u5373\u53ef<\/p>\n<ol class=\"hljs-ln\">\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\"><span class=\"hljs-comment\"># \u5199\u5165openssl\u5e93\u6587\u4ef6\u7684\u641c\u7d22\u8def\u5f84<\/span><\/div>\n<\/div><\/li>\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\"><span class=\"hljs-built_in\">echo<\/span> <span class=\"hljs-string\">&#8220;\/usr\/local\/openssl\/lib&#8221;<\/span> >> \/etc\/ld.so.conf <span class=\"hljs-comment\"># \u9700\u8981root\u6743\u9650<\/span><\/div>\n<\/div><\/li>\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\"><\/div><\/li>\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\"><span class=\"hljs-comment\"># \u4f7f\u4fee\u6539\u540e\u7684\/etc\/ld.so.conf\u751f\u6548 <\/span><\/div>\n<\/div><\/li>\n    <li>\n<div class=\"hljs-ln-numbers\"><\/div>\n<div class=\"hljs-ln-code\">\n<div class=\"hljs-ln-line\">ldconfig -v<\/div>\n<\/div><\/li>\n<\/ol>\n<p>\uff087\uff09\u9a8c\u8bc1\u5b89\u88c5\u7ed3\u679c<\/p>\n<img loading=\"lazy\" decoding=\"async\" class=\"has\" src=\"http:\/\/nick.txtcc.com\/wp-content\/uploads\/remote_image\/2020\/08\/060257HGs.png\" alt=\"\" width=\"824\" height=\"72\" \/>\n<p>&nbsp;<\/p>\n<p><strong>\u7b2c\u4e8c\u6b65\uff1a\u5b89\u88c5 LibreSSL<\/strong><\/p>\n<p>\u4ece LibreSSL \u5b98\u7f51 <a href=\"http:\/\/www.libressl.org\/\">http:\/\/www.libressl.org\/<\/a> \u4e0b\u8f7d\u6e90\u4ee3\u7801\u3002\u6b64\u5904\u4f7f\u7528\u201clibressl-2.8.2.tar.gz\u201d\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u4ee5\u6b64\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"hljs cpp\">&lt;span class=&quot;hljs-meta&quot;&gt;#wget https:&lt;span class=&quot;hljs-comment&quot;&gt;\/\/ftp.openbsd.org\/pub\/OpenBSD\/LibreSSL\/libressl-2.8.2.tar.gz&lt;\/span&gt;&lt;\/span&gt;\n&lt;span class=&quot;hljs-meta&quot;&gt;#tar xzvf libressl-2.8.2.tar.gz&lt;\/span&gt;\n&lt;span class=&quot;hljs-meta&quot;&gt;#cd libressl-2.8.2&lt;\/span&gt;\n&lt;span class=&quot;hljs-meta&quot;&gt;#.\/config&lt;\/span&gt;\n&lt;span class=&quot;hljs-meta&quot;&gt;#make&lt;\/span&gt;\n&lt;span class=&quot;hljs-meta&quot;&gt;#make install&lt;\/span&gt;<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>\u6b64\u65f6\u518d\u9a8c\u8bc1 OpenSSL \u7248\u672c\uff0c\u5982\u4e0b\uff1a<\/p>\n<pre class=\"pure-highlightjs\"><code class=\"hljs css\">&lt;span class=&quot;hljs-selector-id&quot;&gt;#openssl&lt;\/span&gt; &lt;span class=&quot;hljs-selector-tag&quot;&gt;version&lt;\/span&gt;\n&lt;span class=&quot;hljs-selector-tag&quot;&gt;LibreSSL&lt;\/span&gt; 2&lt;span class=&quot;hljs-selector-class&quot;&gt;.8&lt;\/span&gt;\n&lt;span class=&quot;hljs-selector-class&quot;&gt;.2&lt;\/span&gt;<\/code><\/pre>","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5\u4e86Python3.7\u4e4b\u540e\uff0c\u9047\u5230\u7684\u4e00\u4e2a\u5f88\u9ebb\u70e6\u7684\u5751\u5c31\u662f\u4e0e\u7cfb\u7edf\u81ea\u5e26\u7684ssl\u7248\u672c\u4e0d\u517c\u5bb9\uff0c\u00a0Python3.7\u9700\u8981\u7684openssl\u7684\u7248\u672c\u4e3a1.0.2\u6216\u80051.1.x\uff0c\u8fd9\u4e2arequirements\u5728config&#46;&#46;&#46;<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,274],"tags":[],"class_list":["post-2107","post","type-post","status-publish","format-standard","hentry","category-linux","category-python"],"_links":{"self":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/2107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/comments?post=2107"}],"version-history":[{"count":2,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/2107\/revisions"}],"predecessor-version":[{"id":2112,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/posts\/2107\/revisions\/2112"}],"wp:attachment":[{"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/media?parent=2107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/categories?post=2107"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/nick.txtcc.com\/index.php\/wp-json\/wp\/v2\/tags?post=2107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}