使用自制程序安装 AWS CLI 时出现错误 [SSL: CERTIFICATE_VERIFY_FAILED]

sno*_*wvy 2 python macos ssl homebrew aws-cli

我的系统是 M1 Mac,配备 macOS 12.3.1,并通过自制软件安装 aws cli,当尝试运行时,aws s3 ls出现错误 SSL validation failed for https://s3.{awsregion}.amazonaws.com/ [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)

我检查了 python3 SSL 路径,命令python3 -c 'import ssl; print(ssl.get_default_verify_paths())' 结果是DefaultVerifyPaths(cafile='/opt/homebrew/etc/openssl@1.1/cert.pem', capath=None, openssl_cafile_env='SSL_CERT_FILE', openssl_cafile='/opt/homebrew/etc/openssl@1.1/cert.pem', openssl_capath_env='SSL_CERT_DIR', openssl_capath='/opt/homebrew/etc/openssl@1.1/certs')

这意味着它使用brew install版本的openssl@1.1并且python3也使用brew install版本python@3.9位置是 /opt/homebrew/bin/python3

我尝试重新安装 awscli、openssl@1.1 和 python@3.9,然后也尝试

  1. 从brew中卸载Python3
  2. 使用 Python 网站的安装程序安装 Python
  3. 在Python文件夹中执行Install Certificates.command
  4. 卸载Python
  5. 从brew安装python@3.9

也给了我同样的错误。

这里有关于我的系统的一些信息

  • M1 Mac - MacOS 12.3.1
  • Python3-brew python@3.9 (3.9.12)
  • OpenSSL - 酿造 openssl@1.1 (1.1.1n)
  • AWS CLI-brew awscli (2.6.0)
  • Xcode CLT - 13.3.1.0.1.1648687083
  • 铿锵 - 13.1.6 版本 1316

有人对这个问题有任何想法吗?先感谢您。

小智 7

将 AWS_CA_BUNDLE 环境变量设置为来自Mozilla的 cert.pem 文件(可在公式“ca-certificates”中找到),如下所示:

export AWS_CA_BUNDLE=$HOMEBREW_PREFIX/etc/ca-certificates/cert.pem

  • $HOMEBREW_PREFIX 没有为我设置,所以我这样做了:export AWS_CA_BUNDLE=$(brew --prefix)/etc/ca-certificates/cert.pem (4认同)