由于证书验证而获取SSLError的请求失败

时间:2016-10-12 18:33:46

标签: python ssl python-requests

我正在使用Python 2.7.3,请求版本2.7.0。我使用自签名证书设置了一个简单的HTTPS服务器。我可以在Windows上运行以下脚本。但我无法在嵌入式设备上执行相同的操作。在嵌入式设备上,我对http get或https使用verify = False没有任何问题。

import requests
url = 'https://192.168.3.4:8002'
requests.get(url, verify='/home/root/server.crt')

错误陈述:

    Traceback (most recent call last):
  File "test.py", line 3, in <module>
    requests.get(url, verify='/home/root/server.crt')
  File "/usr/lib/python2.7/site-packages/requests/api.py", line 69, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/api.py", line 50, in request
    response = session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 465, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 431, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: [Errno bad handshake] [('SSL routines', 'SSL3_GET_SERVER_CERTIFICATE', 'certificate verify failed')]

有没有人有任何想法?

0 个答案:

没有答案