我想编写webservices来使用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)
不要在生产中使用它.
希望能帮助到你!