简体   繁体   English

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

[英]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: 但是当我运行我的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)

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. 我从其他SO问题安装了所有软件包,但均未成功。 Any idea how to solve this? 任何想法如何解决这个问题?

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

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

相关问题 OpenSSL s_client和Python SSL模块对于主机名的证书不一致 - OpenSSL s_client and Python SSL module disagree on the certificate for a hostname python ssl(相当于 openssl s_client -showcerts )如何从服务器获取客户端证书的 CA 列表 - python ssl (eqivalent of openssl s_client -showcerts ) How to get list of CAs for client certs from server urlopen在Python 2.7中有效,但在Python 3.4中失败 - urlopen works in Python 2.7 but fails in Python 3.4 Python导入可在2.7中使用,但在3.2+中将失败 - Python import works in 2.7 but fails in 3.2+ 无法使用 OpenSSL 的 ssl.SSLContext() 在 Python 客户端中接收对等证书 - Can't receive peer certificate in Python client using OpenSSL's ssl.SSLContext() 在python 2.7中更新openssl - Updating openssl in python 2.7 从源代码构建 Python 和 OpenSSL,但 ssl 模块失败 - Building Python and OpenSSL from source, but ssl module fails Python dict反序列化在python2.7中有效,在3.3中失败 - Python dict deserialization works in python2.7, fails in 3.3 错误:未编译 Python ssl 扩展。 缺少 OpenSSL 库? (在 ubuntu 18.04 上安装 python 2.7) - ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib? (installing python 2.7 on ubuntu 18.04) Elasticsearch 无法连接 python 客户端,ssl 错误 - Elasticsearch cannot connect with python client, ssl error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM