TLS CA 证书在数据流作业中失败

问题描述 投票:0回答:1

我使用 Python Apache Beam 创建了自定义数据流模板。在模板逻辑中,我使用 Python 请求调用 Rest api。我想使用 CA 证书对 api 调用进行身份验证,但在数据流作业中出现以下错误。

找不到合适的 TLS CA 证书捆绑包,无效路径:/extra_files/cert.pem

我已将 cert.pem 保存在 GCP 存储桶中,并尝试使用以下命令访问它

--extraFilesToStage:gs://bucket/cert.pem

请求代码是:

Resp = requests.get(url, verify='/extra_files/cert.pem', beaders=headers, timeout=120)

这里出了什么问题?

ssl google-cloud-platform ssl-certificate certificate google-cloud-dataflow
1个回答
0
投票

查看上一个问题,似乎是一些安装和依赖项问题,您可以尝试一些发布的解决方案here(如果适用)?

您需要允许 pip 引用正确的证书。首先检查>证书;

python -c "import certifi; print(certifi.where())"

那就先手动测试一下;

pip install -r requirements.txt --cert=<the above certificate path>

如果工作正常,则更新位于 >$HOME/.pip/pip.conf(或 Windows 上的 %APPDATA%\pip\pip.ini)的 pip.conf 文件上的此路径。例如

[global]
cert = /usr/local/share/ca-certificate/mycert.crt
© www.soinside.com 2019 - 2024. All rights reserved.