python - SSLError ("bad handshake") 尝试访问资源自定义证书和请求时

标签 python pfx zeep

我想使用 Zeep 在 Python 中对网络服务进行编程以交换数据。我只能使用我的证书访问服务。我有一个 PFX 证书,但我将它转换为两个 .pem 文件。

我的代码:

from zeep import Client
from zeep.wsse.signature import Signature 
import requests
from requests import Session
key_filename ='/.files/cert.key.pem'
cert_filename = './files/cert.crt.pem'
session = Session()  
r = requests.get('https:...../PingWs?wsdl',
             cert=(cert_filename, key_filename)) 
print (r)

但是我明白了

> raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='evidim-test.gov.si', port=443):
Max retries exceeded with url: /ws/test/PingWs?wsdl
(Caused by SSLError(SSLError("bad handshake: Error([('SSL routines',
'tls_process_server_certificate', 'certificate verify failed')],)",),))

最佳答案

这是一个您必须通过将用于签署您尝试从系统设置连接到的远程服务器证书的 CA 证书列入白名单来解决的问题。但仅出于测试目的,您可以使用以下方式关闭验证:

r = requests.get('https:...../PingWs?wsdl',verify=False)

不要在生产中使用它。

希望对您有所帮助!

关于python - SSLError ("bad handshake") 尝试访问资源自定义证书和请求时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47208466/

相关文章:

windows - 如何将 pem 文件转换为 pfx 文件?

python - 创建要传递给 zeep 的 xml 格式

python - Pylint 提示在另一个文件中设置的实例的成员

python - Pyhdfs copy_from_local 导致提供节点名或服务名,或未知错误

python - 如何找出Python正则表达式中组匹配的次数?

Python Zeep - HTTP 状态 415(无可用内容)

python 泽普。强制不使用代理

python - 当安装多个版本的 python 时,tox 使用错误版本的 pip

pfx - 不使用 OpenSSL 从 PFX 文件中提取证书

c# - 如何使用 C# 从本地机器存储读取 PFX 证书