尝试访问资源自定义证书和请求时出现SSLError(“握手失败") [英] SSLError("bad handshake") when trying to access resources Custom Certificates and Requests

查看:819
本文介绍了尝试访问资源自定义证书和请求时出现SSLError(“握手失败")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to program webservices to exchange data in Python using Zeep. I can access services only with my certificate. I have a PFX certificate, but I converted it to two .pem files.

我的代码:

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证书列入白名单.但仅出于测试目的,您可以使用以下方法关闭验证:

Its an issue you will have to resolve by whitelisting the CA certificate used to sign the remote server certificate you are trying to connect to from your system settings. But for the purposes of testing out only, you can turn off the verification using:

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

请勿在生产中使用它.

希望有帮助!

这篇关于尝试访问资源自定义证书和请求时出现SSLError(“握手失败")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆