简体   繁体   English

Python-如何解决 ssl.SSLError: [SSL: CA_MD_TOO_WEAK]

[英]Python-How to solve ssl.SSLError: [SSL: CA_MD_TOO_WEAK]

I've got a huge problem with authorization of my API request.我的 API 请求的授权遇到了一个大问题。 I'm using python 3.10.我正在使用 python 3.10。 For setting up the client I have code as follows:为了设置客户端,我有如下代码:

from zeep import exceptions, helpers
from requests import Session
from zeep.transports import Transport
from zeep import Client

def login(register):
.......
elif register == 'XXX':
  authTok = '' #only for coherence
  wsdl_path = r"path_to_my_wsdl.wsdl"
  url = urllib.parse.urljoin('file:', urllib.request.pathname2url(os.path.abspath(wsdl_path)))
  session = Session()
  session.verify = False
  session.cert = (r'path_to_my_cert.pem')
  client = Client(wsdl=url, transport=Transport(session=session))
return client, authTok

Then I used code below to get the client:然后我使用下面的代码来获取客户端:

client, authTok = login('XXX')
search = {}
search['sort'] = {'sort_att': 'number',
                  'sort_asc': 'True'}
search['criterion'] = {'search_range': 'RP', 'id': '123456789'}

No error till this step.直到这一步没有错误。 And finally I've tried to send my request like this: r = client.service.searchcompany(params=search)最后我尝试像这样发送我的请求: r = client.service.searchcompany(params=search)

Here I got error like this:在这里我得到这样的错误:

ssl.SSLError: [SSL: CA_MD_TOO_WEAK] ca md too weak (_ssl.c:3862)

With openssl I've generated new cert:使用 openssl 我生成了新证书:

openssl req -x509 -newkey rsa:4096 -keyout key.pem -out mycert.pem -sha256 -days 365 -nodes

As the output I've received two files: key.pem and mycert.pem.作为 output,我收到了两个文件:key.pem 和 mycert.pem。 With command certifi.where() I found location of my file cacert.pem and pasted into it the content of file mycert.pem.使用命令certifi.where()我找到了文件 cacert.pem 的位置并将文件 mycert.pem 的内容粘贴到其中。

Unfortunately the error still occurs.不幸的是,错误仍然发生。 Could anybody explain what I'm doing wrong?谁能解释我做错了什么?

In my case it was helpful to downgrade the version of python to 3.8.8.就我而言,将 python 的版本降级到 3.8.8 很有帮助。 That solved my error.这解决了我的错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何解决 SSL 问题 SSL_CTX_use_certificate: ca md too weak on Python Zeep - How to fix SSL issue SSL_CTX_use_certificate : ca md too weak on Python Zeep 使用 Ubuntu 20.4 和 Python Imaplib:我可以覆盖 ssl.SSLError:[SSL:DH_KEY_TO_OSMALL] - Using Ubuntu 20.4 & Python Imaplib: Can I override ssl.SSLError: [SSL: DH_KEY_TOO_SMALL]? python ssl ssl.SSLError: [SSL: UNSUPPORTED_PROTOCOL] 不支持的协议 (_ssl.c:590) - python ssl ssl.SSLError: [SSL: UNSUPPORTED_PROTOCOL] unsupported protocol (_ssl.c:590) 蝗虫 - Python - ssl.SSLError: [SSL] PEM lib (_ssl.c:4065) - Locust - Python - ssl.SSLError: [SSL] PEM lib (_ssl.c:4065) Python ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败 (_ssl.c:748) - Python ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748) Python中的Azure服务管理 - ssl.SSLError:[SSL] PEM lib(_ssl.c:2084) - Azure Service Management in Python - ssl.SSLError: [SSL] PEM lib (_ssl.c:2084) 使用 urllib3 时 ssl.SSLError - ssl.SSLError when using urllib3 获取 ssl.SSLError: [X509] 在 python 中找不到证书或 crl (_ssl.c:4062) - getting ssl.SSLError: [X509] no certificate or crl found (_ssl.c:4062) in python ssl.SSLError: ('No cipher can be selected') 当试图在 Python ZEA52C36203C5F99C3CE2ZZ442D531B1A2 中设置 TLS1.3 密码套件时 - ssl.SSLError: ('No cipher can be selected') When Trying to Set TLS1.3 Cipher Suites in Python SSL ssl.SSLError:[SSL:CERTIFICATE_VERIFY_FAILED]证书验证失败的Python - ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM