繁体   English   中英

为什么当openssl s_client -connect工作时,python 2.7对ssl的请求失败?

[英]Why python 2.7 request fails for ssl when openssl s_client -connect works?

我正在尝试使用自签名证书签名的服务器。 我有

openssl s_client -connect myserveraddress:myport 

工作的

---
SSL handshake has read 4620 bytes and written 466 bytes
---

但是当我运行我的python代码时:

import requests

url = MyURL

querystring = {"q":"admin"}

headers = {
'content-type': "application/json",
'authorization': "Bearer SOME-TOKEN",
'cache-control': "no-cache"
}

response = requests.request("GET", url, headers=headers, params=querystring, verify=False)

它失败:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 502, in request
    resp = self.send(prep, **send_kwargs)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 612, in send
    r = adapter.send(request, **kwargs)
  File "/Library/Python/2.7/site-packages/requests/adapters.py", line 514, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:590)

我从其他SO问题安装了所有软件包,但均未成功。 任何想法如何解决这个问题?

通过从2.7.10升级到python 2.7.13并安装开放的SSL软件包并将自签名证书添加到存储中,解决了问题

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM