我正在用 python 中的请求调用 REST API,到目前为止,当我设置verify=False
.
现在,我必须使用需要导入以进行身份验证的客户端证书,并且每次使用cert (.pfx). cert.pfx
受密码保护时都会收到此错误。
r = requests.post(url, params=payload, headers=headers,
data=payload, verify='cert.pfx')
这是我得到的错误:
Traceback (most recent call last):
File "C:\Users\me\Desktop\test.py", line 65, in <module>
r = requests.post(url, params=payload, headers=headers, data=payload, verify=cafile)
File "C:\Python33\lib\site-packages\requests\api.py", line 88, in post
return request('post', url, data=data, **kwargs)
File "C:\Python33\lib\site-packages\requests\api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python33\lib\site-packages\requests\sessions.py", line 346, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python33\lib\site-packages\requests\sessions.py", line 449, in send
r = adapter.send(request, **kwargs)
File "C:\Python33\lib\site-packages\requests\adapters.py", line 322, in send
raise SSLError(e)
requests.exceptions.SSLError: unknown error (_ssl.c:2158)
我也尝试过 openssl 来获取.pem
和密钥,但使用.pem
和获取SSL: CERTIFICATE_VERIFY_FAILED
有人可以指导我如何导入证书以及将其放置在哪里?我尝试搜索但仍然面临同样的问题。