解決repo init 錯誤SSL: CERTIFICATE_VERIFY_FAILED

如果像我的LINUX第一次安裝或使用REPO的功能。
執行repo init指令一直出現類似SSL: CERTIFICATE_VERIFY_FAILED警報時。

也許是因為該主機的CERT檔案沒有更新過。
可以嘗試:
sudo update-ca-certificates
export SSL_CERT_DIR=/etc/ssl/certs

會更新網路的認證檔案,然後這時候再執行repo init指令應該就不會再出現SSL的錯誤問題了。

方法二,如果確定是python造成的問題。
可以嘗試用這個.PY文件來克服,存檔執行一次應該就會更新好相關的certificates。
我是一般user和sudo都有執行一次。

#!/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://pypi.org/project/certifi/

import os
import os.path
import ssl
import stat
import subprocess
import sys

STAT_0o775 = ( stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR
| stat.S_IRGRP | stat.S_IWGRP | stat.S_IXGRP
| stat.S_IROTH | stat.S_IXOTH )

def main():
openssl_dir, openssl_cafile = os.path.split(
ssl.get_default_verify_paths().openssl_cafile)

print(" -- pip install --upgrade certifi")
subprocess.check_call([sys.executable,
"-E", "-s", "-m", "pip", "install", "--upgrade", "certifi"])

import certifi

# change working directory to the default SSL directory
os.chdir(openssl_dir)
relpath_to_certifi_cafile = os.path.relpath(certifi.where())
print(" -- removing any existing file or link")
try:
os.remove(openssl_cafile)
except FileNotFoundError:
pass
print(" -- creating symlink to certifi certificate bundle")
os.symlink(relpath_to_certifi_cafile, openssl_cafile)
print(" -- setting permissions")
os.chmod(openssl_cafile, STAT_0o775)
print(" -- update complete")

if __name__ == '__main__':
main()
EOF

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

請輸入下列驗證碼計算後阿拉伯數字 (Translate it, if not Taiwanese to post reply) *