{"id":3027,"date":"2022-12-22T22:15:52","date_gmt":"2022-12-22T14:15:52","guid":{"rendered":"https:\/\/jir.idv.tw\/wordpress\/?p=3027"},"modified":"2022-12-23T19:43:48","modified_gmt":"2022-12-23T11:43:48","slug":"%e8%a7%a3%e6%b1%barepo-init-%e9%8c%af%e8%aa%a4ssl-certificate_verify_failed","status":"publish","type":"post","link":"https:\/\/jir.idv.tw\/wordpress\/?p=3027","title":{"rendered":"\u89e3\u6c7arepo init \u932f\u8aa4SSL: CERTIFICATE_VERIFY_FAILED"},"content":{"rendered":"<p>\u5982\u679c\u50cf\u6211\u7684LINUX\u7b2c\u4e00\u6b21\u5b89\u88dd\u6216\u4f7f\u7528REPO\u7684\u529f\u80fd\u3002<br \/>\n\u57f7\u884crepo init\u6307\u4ee4\u4e00\u76f4\u51fa\u73fe\u985e\u4f3cSSL: CERTIFICATE_VERIFY_FAILED\u8b66\u5831\u6642\u3002<br \/>\n<urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1056)><\/p>\n<p>\u4e5f\u8a31\u662f\u56e0\u70ba\u8a72\u4e3b\u6a5f\u7684CERT\u6a94\u6848\u6c92\u6709\u66f4\u65b0\u904e\u3002<br \/>\n\u53ef\u4ee5\u5617\u8a66:<br \/>\n<code>sudo update-ca-certificates<br \/>\nexport SSL_CERT_DIR=\/etc\/ssl\/certs<\/code><br \/>\n\u6703\u66f4\u65b0\u7db2\u8def\u7684\u8a8d\u8b49\u6a94\u6848\uff0c\u7136\u5f8c\u9019\u6642\u5019\u518d\u57f7\u884crepo init\u6307\u4ee4\u61c9\u8a72\u5c31\u4e0d\u6703\u518d\u51fa\u73feSSL\u7684\u932f\u8aa4\u554f\u984c\u4e86\u3002<\/p>\n<p>\u65b9\u6cd5\u4e8c\uff0c\u5982\u679c\u78ba\u5b9a\u662fpython\u9020\u6210\u7684\u554f\u984c\u3002<br \/>\n\u53ef\u4ee5\u5617\u8a66\u7528\u9019\u500b.PY\u6587\u4ef6\u4f86\u514b\u670d\uff0c\u5b58\u6a94\u57f7\u884c\u4e00\u6b21\u61c9\u8a72\u5c31\u6703\u66f4\u65b0\u597d\u76f8\u95dc\u7684certificates\u3002<br \/>\n\u6211\u662f\u4e00\u822cuser\u548csudo\u90fd\u6709\u57f7\u884c\u4e00\u6b21\u3002<\/p>\n<p><code>#!\/bin\/sh<br \/>\n# install_certifi.py<br \/>\n#<br \/>\n# sample script to install or update a set of default Root Certificates<br \/>\n# for the ssl module.  Uses the certificates provided by the certifi package:<br \/>\n#       https:\/\/pypi.org\/project\/certifi\/<\/p>\n<p>import os<br \/>\nimport os.path<br \/>\nimport ssl<br \/>\nimport stat<br \/>\nimport subprocess<br \/>\nimport sys<\/p>\n<p>STAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR<br \/>\n             | stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP<br \/>\n             | stat.S_IROTH |                stat.S_IXOTH )<\/p>\n<p>def main():<br \/>\n    openssl_dir, openssl_cafile = os.path.split(<br \/>\n        ssl.get_default_verify_paths().openssl_cafile)<\/p>\n<p>    print(\" -- pip install --upgrade certifi\")<br \/>\n    subprocess.check_call([sys.executable,<br \/>\n        \"-E\", \"-s\", \"-m\", \"pip\", \"install\", \"--upgrade\", \"certifi\"])<\/p>\n<p>    import certifi<\/p>\n<p>    # change working directory to the default SSL directory<br \/>\n    os.chdir(openssl_dir)<br \/>\n    relpath_to_certifi_cafile = os.path.relpath(certifi.where())<br \/>\n    print(\" -- removing any existing file or link\")<br \/>\n    try:<br \/>\n        os.remove(openssl_cafile)<br \/>\n    except FileNotFoundError:<br \/>\n        pass<br \/>\n    print(\" -- creating symlink to certifi certificate bundle\")<br \/>\n    os.symlink(relpath_to_certifi_cafile, openssl_cafile)<br \/>\n    print(\" -- setting permissions\")<br \/>\n    os.chmod(openssl_cafile, STAT_0o775)<br \/>\n    print(\" -- update complete\")<\/p>\n<p>if __name__ == '__main__':<br \/>\n    main()<br \/>\nEOF<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u679c\u50cf\u6211\u7684LINUX\u7b2c\u4e00\u6b21\u5b89\u88dd\u6216\u4f7f\u7528REPO\u7684\u529f\u80fd\u3002 \u57f7\u884crepo init\u6307\u4ee4\u4e00\u76f4\u51fa\u73fe\u985e\u4f3cSSL: CERTIFICATE_VERIFY_FAILED\u8b66\u5831\u6642\u3002 \u4e5f\u8a31\u662f\u56e0\u70ba\u8a72\u4e3b\u6a5f\u7684CERT\u6a94\u6848\u6c92\u6709\u66f4\u65b0\u904e\u3002 \u53ef\u4ee5\u5617\u8a66: sudo update-ca-certificates export SSL_CERT_DIR=\/etc\/ssl\/certs \u6703\u66f4\u65b0\u7db2\u8def\u7684\u8a8d\u8b49\u6a94\u6848\uff0c\u7136\u5f8c\u9019\u6642\u5019\u518d\u57f7\u884crepo init\u6307\u4ee4\u61c9\u8a72\u5c31\u4e0d\u6703\u518d\u51fa\u73feSSL\u7684\u932f\u8aa4\u554f\u984c\u4e86\u3002 \u65b9\u6cd5\u4e8c\uff0c\u5982\u679c\u78ba\u5b9a\u662fpython\u9020\u6210\u7684\u554f\u984c\u3002 \u53ef\u4ee5\u5617\u8a66\u7528\u9019\u500b.PY\u6587\u4ef6\u4f86\u514b\u670d\uff0c\u5b58\u6a94\u57f7\u884c\u4e00\u6b21\u61c9\u8a72\u5c31\u6703\u66f4\u65b0\u597d\u76f8\u95dc\u7684certificates\u3002 \u6211\u662f\u4e00\u822cuser\u548csudo\u90fd\u6709\u57f7\u884c\u4e00\u6b21\u3002 #!\/bin\/sh # install_certifi.py # # sample script to install or update a set of default Root Certificates # for the ssl module. Uses the certificates provided by the certifi package: # https:&#8230; <a href=\"https:\/\/jir.idv.tw\/wordpress\/?p=3027\" class=\"readmore\">Read more (\u5b8c\u6574\u6587\u7ae0\u5167\u5bb9)<span class=\"screen-reader-text\">\u89e3\u6c7arepo init \u932f\u8aa4SSL: CERTIFICATE_VERIFY_FAILED<\/span><span class=\"fa fa-angle-double-right\" aria-hidden=\"true\"><\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-3027","post","type-post","status-publish","format-standard","hentry","category-4","content-layout-excerpt-thumb"],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/jir.idv.tw\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/3027","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jir.idv.tw\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jir.idv.tw\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jir.idv.tw\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jir.idv.tw\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3027"}],"version-history":[{"count":3,"href":"https:\/\/jir.idv.tw\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/3027\/revisions"}],"predecessor-version":[{"id":3030,"href":"https:\/\/jir.idv.tw\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/3027\/revisions\/3030"}],"wp:attachment":[{"href":"https:\/\/jir.idv.tw\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3027"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jir.idv.tw\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3027"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jir.idv.tw\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3027"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}