- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
查看更新
我正在尝试使用自签名证书向网络服务器发送请求(在非自签名的网站上工作正常),但我不断收到错误:
SSLEOFERROR EOF occurred in violation of protocol
相反,当使用 requests 时,Python 的非异步 http 客户端将 ssl_verify 设置为 false 可以成功连接到服务器。然而,异步http客户端询问,缺乏这样的功能,我得到了SSLEOFERROR。
Asks 确实允许接受自定义的 ssl.SSLContext 对象,但经过多次尝试,甚至将自签名证书添加到我的本地 keystore 中,没有任何结果导致成功连接,并且错误保持不变。
import asks
import trio
from asks.sessions import Session
url_list = ['facebook.com', 'https://example.com']
results=[]
ssl_context=ssl.SSLContext()
ssl_context.verify_mode=ssl.CERT_NONE
ssl_context.check_hostname = False
async def grabber(s,url):
r=await s.get(path='/'+url)
results.append(r)
async def main(url_list)
s = Session(connections=2,ssl_context=ssl_context)
s.base_location='https://self-signedcert-site/'
s.endpoint='path/to/restapi'
async with trio.open_nursery() as n:
for url in url_list:
n.start_soon(grabber, s, url)
trio.run(main,url_list)
结果如下(手写回溯..无法从错误机器共享/粘贴)开始SSLEOFERROR回溯:
Traceback (most recent call last):
line 463 in _retry
ret = fn(*args)
line 718 in read
v= self._sslobj.read(len)
ssl.SSLEOFError: EOF occured in violation of protocol (_ssl.c:2508)
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
line 90, in runcode
exec(code, self.locals)
File "<input>", line 28, in <module> run.py line 1783 in run
raise runner.main_task_outcome.error
file"<input>", line 26 in main
file _run.py, line 725, in __aexit__
raise combined error_from_nursery
file"<input>", line 15 in grabber
File "asks/sessions.py", line 253, in _handle_exception
raise e
File ...asks\sessions.py" , line 186 in request
sock,r = await req_obj.make_request()
file ...request_object.py ", line 217 in make_request
response obj=await self._request_io(req, req_body, hconnection)
file ..request_object.py", line 254 in _request_io
response_obj = await
self._catch_response(hcconection)
file ..request_object.py", line 596, in _catch_response
data=await self._recv_event(hcconection)
file "...request_object.py", line 618, in _recv_event
(await asynclib.recv(self.sock,10000)))
File "..._event_loop_wrappers.py", line 47 in trio_receive_some
return await sock.receive_some(max_bytes)
file "..._ssl.py" line 657 in receive_some
return await self._retry(self._ssl_object.read, max_bytes)
File"....trio\_ssl.py", line 468 in _retry
raise trio.BrokenResourceerror from exc
Trio.BrokenResourceError
更新我已经确定了一些事情。
如果我不使用 session 对象,而只使用 asks.get()
,我就能够看到响应中的细微变化:
询问图书馆
<小时/>SSLEOFERROR: [使用 pip 安装修复的错误询问 -- conda-forge 运行落后 3 个版本]
asks.get('https://url', auth=BasicAuth(usr_pw))
无效的 HTTP 响应错误:
asks.get('https:url/rest/api/path',auth=BasicAuth(usr_pw))
页面正文按预期返回:
asks.get('https://google.com')
请求库
<小时/>页面正文按预期返回:
requests.get('https://url', auth=HTTPBasicAuth=(usr_pw),verify=false)
API 按预期返回正确的响应:
requests.get('https:url/rest/api/path', auth=HTTPBasicAuth=(usr_pw))
考虑到我能够生成另一种类型的错误(无效的http响应),我为此添加了更多回溯开始无效 HTTP 响应回溯:
[完整路径已编辑]
File "....\asks\sessions.py", line 185, in request
sock, r = await req_obj.make_request()
file ....\asks\request_object.py", line 214, in make_request
response_obj = await self._request_io(req, req_body, h11_connection)
file "...\asks\request_object.py", line 251, in _request_io
response_obj = await self._catch_response(h11_connection)
file"...\asks\request_object.py", line 599, in _catch_response
assert isinstance(endof, h11.EndOfMessage)
AssertionError
The above exception was the direct cause of the following exception
[some output redacted]
file "...\trio\_core\_run.py", in 1783, in run
raise runner.main_task_outcome.error
file "...\my_script_thats_having_this_error, line 33, in main
n.start_soon(grabber,s)
File"....\trio\_core\_run.py", line 725 in __aexit__
raise combined_error_from_nursery
File "...\my_script_thats_having_this_error, line 30 in request
r = await s.request(method, url=uri, **kwargs)
File "...\asks\sessions.py", line 215, in request
await self._handle_exception(e,sock)
File "...\asks\sessions.py", line 253, in _handle_exception
raise BadHttpResponse('invalid HTTP response from server. ') from e asks.errors.BadHttpResponse: Invalid HTTP response from server.
最佳答案
我尝试使用 asks
v2.3.5 连接到具有自签名证书的站点,并且成功了:
>>> trio.run(asks.get, "https://self-signed.badssl.com")
<Response 200 OK>
这是一个严重的错误...这意味着要求实际上默认设置了与 verify=False
等效的内容。我预计 requests 将在未来几天内发布紧急版本来解决此问题。请参阅:https://github.com/theelous3/asks/issues/134 [编辑:此问题已在 requests v2.3.6 中修复。]
回到你的问题!鉴于默认情况下会询问 verify=False
,我认为自签名证书不会导致您的问题。无论如何,自签名证书应该导致 SSLCertVerificationError
,而不是 SSLEOFError
。
不幸的是,我认为这里没有足够的信息来弄清楚您的实际问题是什么:-(。SSLEOFError
异常意味着服务器突然关闭其连接。也许出了问题在握手中?也许询问和请求被配置为提供一组不同的密码套件,而服务器不喜欢询问的提供?不过这些都是疯狂的猜测:-/。接下来我可能会尝试使用wireshark来找出实际情况正在发生。
关于python - "asks"异步 https 客户端 : 'SSLEOFERROR on connect attempt to server with self-signed cert --WARNING: handtyped stack trace--,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57742649/
你发现标题的不同了吗? (对我来说,花了一些时间) 所以我按顺序使用了连接到 java.security.cert.X509Certificate 的充气城堡创建证书。现在我正在寻找一种从原始字节创建
我有一整天都在努力解决的问题,但就是无法重建。我遇到了引发 CertificateNotYetValidException 异常的问题: java.security.cert.CertificateN
我有一个服务器和一个客户端。我让他们都在同一台机器上运行。我正在尝试在客户端和服务器之间建立 SSL 连接。我已经使用以下 keytool 命令为服务器和客户端生成了证书。 对于客户keytool -
在本地,我一直在使用一个 Nginx 容器进行开发,该容器在一个目录中包含所有 ssl 配置和 ssl 证书。 但是,既然我即将转向生产,我很好奇将证书放在 nginx 容器中是否是一种好的做法? 或
我想根据 CRL 验证客户端提供的 X509 证书是否已被吊销。我已经成功地实例化了一个 java.security.cert.X509CRL,但是我在检索 session 证书时遇到了问题: try
我在使用 X509TrustManager 检查服务器是否可信时收到异常错误。我按照开发人员的说明进行操作:https://developer.android.com/training/article
我正在尝试使用 Java 代码从安全(即 SSL)网页中读取内容。我正在尝试同时使用 URLConnection (java.net) 和 Apache 的 HTTPClient。在这两种情况下,当我
如果我仅使用证书(带链)和私钥发出 openssl 调用,我会遇到服务器拒绝握手中的客户端证书的问题。 如果我还设置了 cafile 参数并将其指向与证书相同的文件,这个问题就会消失。 即使信息已经在
我正在使用由 CA 文件签名的证书来保护 kubernetes API。为此,我将我的 CA 文件 sa.crt 添加到 /etc/pki/ca-trust/source/anchors/ 并使用命令
我使用facepy与python进行GAE 我遇到了一个错误,当我跟踪该错误时,我发现 from . import certs 在utils.py文件中 点(.)是什么意思? certs.py 与 u
本文整理了Java中org.bouncycastle.cert.X509CRLHolder类的一些代码示例,展示了X509CRLHolder类的具体用法。这些代码示例主要来源于Github/Stack
本文整理了Java中org.bouncycastle.cert.X509v2CRLBuilder类的一些代码示例,展示了X509v2CRLBuilder类的具体用法。这些代码示例主要来源于Github
本文整理了Java中org.bouncycastle.cert.X509ExtensionUtils类的一些代码示例,展示了X509ExtensionUtils类的具体用法。这些代码示例主要来源于Gi
本文整理了Java中org.bouncycastle.cert.X509AttributeCertificateHolder类的一些代码示例,展示了X509AttributeCertificateHo
我按照此说明在我的 EKS 集群上设置了一个证书管理器 https://cert-manager.io/docs/tutorials/acme/ingress/ . 这是我的入口 apiVersion
遵循https://cert-manager.io/docs/installation/kubernetes/中提到的步骤 # Kubernetes 1.16+ $ kubectl apply --v
我按照此说明在我的 EKS 集群上设置了一个证书管理器 https://cert-manager.io/docs/tutorials/acme/ingress/ . 这是我的入口 apiVersion
过去 2 天我遇到了此错误。这似乎是 python requests 库的问题,但我已经重新安装了好几次了,但没有成功。 Traceback (most recent call last):
我有一台运行 Debian 8.1、Apache 2.4.10 和 OpenSSL 1.0.1k 的服务器。我有一个域 example.com,其中包含几个子域,例如 www.example.com、
我正在使用 cUrl 从公司网站请求数据,使用他们发送给我的 .cer 证书。这是命令: cUrl --header "Content-Type: text/xml;charset=UTF-8" \
我是一名优秀的程序员,十分优秀!