简体   繁体   English

SSL:SSLV3_ALERT_HANDSHAKE_FAILURE sslv3 警报握手失败 (_ssl.c:833)

[英]SSL: SSLV3_ALERT_HANDSHAKE_FAILURE sslv3 alert handshake failure (_ssl.c:833)

I have a simple TLS client in python running in Ubuntu 18.04 and openssl version 1.1.0g.我在 Ubuntu 18.04 和 openssl 版本 1.1.0g 中运行的 python 中有一个简单的 TLS 客户端。 The client supports a single ciphersuite.客户端支持单个密码套件。 I get an error when trying to connect to a TLS 1.0 server.尝试连接到 TLS 1.0 服务器时出现错误。 The cipher suite is not supported by the server.服务器不支持密码套件。 I know that the reason for the error is most likely due to lack of ciphersuite mismatch but I am looking for a more meaningful error for the user in this case.我知道错误的原因很可能是由于缺乏密码套件不匹配,但在这种情况下我正在为用户寻找更有意义的错误。 The error I am getting at the moment is pointing to SSLv3 which neither the client nor the server has anything to do with SSLv3.我目前得到的错误指向 SSLv3,客户端和服务器都与 SSLv3 无关。 The client disables SSLv3 and the server as well.客户端也禁用 SSLv3 和服务器。 This is the error :这是错误:

[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:833) 

My question is: I need a better error message says for example (lack of ciphersuite mismatch or something like that is relevant to ciphersuite issue).我的问题是:我需要一个更好的错误消息,例如(缺乏密码套件不匹配或与密码套件问题相关的类似内容)。 Is there any?有没有? Of course I could write my own message but the socket connection can fail for various reasons and I can not make a general error that always says "ciphersuite mismatch".当然,我可以编写自己的消息,但套接字连接可能会因各种原因而失败,而且我不能犯一个总是说“密码套件不匹配”的一般错误。

This is the client script:这是客户端脚本:

import socket,ssl
import itertools

context = ssl.SSLContext()

context.verify_mode = ssl.CERT_NONE
context.check_hostname = False

ciphers = "ECDHE-ECDSA-AES128-GCM-SHA256"
context.set_ciphers(ciphers)

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

domainName = "privatedomain.com"
sslSocket = context.wrap_socket(s, server_hostname = domainName)

try:
    sslSocket.connect((domainName, 443))
except (ssl.SSLError, ssl.SSLEOFError, ssl.CertificateError,ssl.SSLSyscallError, ssl.SSLWantWriteError, ssl.SSLWantReadError,ssl.SSLZeroReturnError) as e:
    print("Error: ",e)
sslSocket.close()

From the client's view, it is not possible to get another message than the one sent by the server, which is handshake failure in your case.从客户端的角度来看,除了服务器发送的消息之外,不可能获得另一条消息,这在您的情况下是handshake failure The error message are, for example, documented in RFC 2246 7.2.例如,错误消息记录在RFC 2246 7.2 中。

The reason why you see SSLv3 in your message, is that you probably send a SSLv3 Hello, which is something allowed to negotiate a TLS 1.0 or later protocol.您在消息中看到 SSLv3 的原因是您可能发送了 SSLv3 Hello,这是允许协商 TLS 1.0 或更高版本协议的内容。

Late answer but hopefully helpful .迟到的答案,但希望有帮助。 . . . .

Both client and server must agree on the transport layer version for the connection to be successful.客户端和服务器都必须就传输层版本达成一致才能成功连接。 Consider meeting a person for the first time.考虑第一次见一个人。 The person (client) extends their hand to you (server) in a gesture of greeting.人(客户)以问候的姿态向您(服务器)伸出手。 If you just saw the person come out of the latrine without washing hands and you see (and/or smell) something undesirable, you will not extend your hand in return.如果您只是看到那个人没有洗手就从厕所出来,并且您看到(和/或闻到)了一些不受欢迎的东西,您将不会伸出手作为回报。

It is similar with an SSL handshake.它与 SSL 握手类似。 The client says "Hey I'd like to communicate via TLS v1.0".客户说“嘿,我想通过 TLS v1.0 进行通信”。 The savvy admin for the server knows TLS v1.0 is not secure and they have disabled it on the server--so the server responds to the client, "No, but how about version 1.3?"精明的服务器管理员知道 TLS v1.0 不安全,他们在服务器上禁用了它——所以服务器响应客户端,“不,但是 1.3 版怎么样?” (ie: "Go wash your hands first"). (即:“先洗手”)。 If the client accepts (washes hands), the handshake is accepted and the connection is established.如果客户端接受(洗手),则接受握手并建立连接。 If the client refuses, the server keeps asking for lower versions ("How about a gallon of Purell then?") until the client accepts or the server has no other versions to offer (walks away).如果客户端拒绝,服务器会不断询问低版本(“那么一加仑 Purell 怎么样?”)直到客户端接受或服务器没有其他版本可以提供(走开)。

Basically, the handshake is designed to use the highest version that both the client and server support.基本上,握手旨在使用客户端和服务器都支持的最高版本。

This page has a nice table of versions for client & server (about half way down in the "SSL Contexts" section:这个页面有一个很好的客户端和服务器版本表(大约在“SSL 上下文”部分的一半:

 https://docs.python.org/3/library/ssl.html

Note that TLS v1.0 is no longer considered secure (Google "POODLE attack").请注意,TLS v1.0 不再被认为是安全的(谷歌“POODLE 攻击”)。 If your server supports it, disable it ASAP.如果您的服务器支持它,请尽快禁用它。

For me this:对我来说:

 urllib.error.URLError: <urlopen error [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:1123)>

meant I was doing this意味着我在做这个

        cipherstr = 'MEDIUM:!aNULL:!eNULL'
        context = ssl._create_unverified_context()
        context.set_ciphers(cipherstr)

commenting out the set_ciphers and it works now.注释掉set_ciphers并且它现在可以工作了。

Other thing to check: make sure your version of OpenSSL is new enough .其他要检查的事情:确保您的 OpenSSL 版本足够新

暂无
暂无

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

相关问题 连接到 rabbitmq SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 警报握手失败 (_ssl.c:1108) - connect to rabbitmq SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:1108) requests.exceptions.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 警报握手失败 (_ssl.c:590) - requests.exceptions.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:590) 如何找出此错误的含义:[SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 警报握手失败 (_ssl.c:1129) - How to find out what this error means: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:1129) SSLError:sslv3警报握手失败 - SSLError: sslv3 alert handshake failure 带有证书 SSLv3 警报握手失败的 URLLib - URLLib with cert SSLv3 alert handshake failure 使用urllib2进行SSLv3警报握手失败 - SSLv3 alert handshake failure with urllib2 带requests.get()的BeautifulSoup错误“ SSL23_GET_SERVER_HELLO:sslv3警报握手失败” - BeautifulSoup error with requests.get() “SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure” Python-SSLV3_ALERT_HANDSHAKE_FAILURE,这是密码还是证书问题? - Python - SSLV3_ALERT_HANDSHAKE_FAILURE, is this a cipher or a cert issue? python3 和请求:仍然收到“sslv3 警报握手失败” - python3 and requests: still getting 'sslv3 alert handshake failure' Python下的间歇性“sslv3警报握手失败” - Intermittent “sslv3 alert handshake failure” under Python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM