简体   繁体   中英

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

I am trying to can a server which is signed with a self-signed certificate. I have

openssl s_client -connect myserveraddress:myport 

working

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

but when I run my python code:

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)

it fails:

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)

I installed all the packages from other SO questions with no success. Any idea how to solve this?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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