Python ssl.SSLError:[SSL] PEM lib

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

我尝试使用带有证书的 python 请求调用 api,但出现错误,

ssl.SSLError:[SSL] PEM 库 (_ssl.c:3554) 我遵循的步骤 --> 将我的证书存储到詹金斯凭证中 --> 在詹金斯中,我将其复制到我的服务器,因为应用程序是本地的 --> 然后在我的 python 脚本中我可以读取该证书,[我的证书是 .cer 格式]

script_directory = os.path.dirname(os.path.abspath(__file__))
certificate_file_path = os.path.join(script_directory, 'hawkeyeCertificate.cer')
response = requests.get(is_epp_api_end_point, headers=access_token, params=params, cert=(certificate_file_path, None))
python ssl pyspark request ssl-certificate
1个回答
0
投票

找到了解决方案,如果您有 .cer 文件,请不要在 cert= 参数中传递它,而是在验证中传递该 cer 文件,

代替这个,

response = requests.get(is_epp_api_end_point, headers=access_token, params=params, cert=(certificate_file_path, None))

用这个,

response = requests.get(is_epp_api_end_point, headers=access_token, params=params, verify= 'my_certificate.cer')
© www.soinside.com 2019 - 2024. All rights reserved.