[英]Error during SSL Handshake with qt
I came to you today because I've got a problem with my Client+Server app. 我今天来找您是因为我的Client + Server应用程序出现问题。 I built a server and client app which were working fine with QTcpSocket but I thought about adding some security and going for QSslSocket with delayed handshake . 我构建了一个服务器和客户端应用程序,它们可以与QTcpSocket一起正常工作,但是我考虑过增加一些安全性,并选择延迟握手的 QSslSocket。 The problem is that my client is acting really weirdly. 问题是我的客户的行为真的很奇怪。 Here is the situation : 这是情况:
connectToHostEncrypted()
in my Client and call startServerEncryption()
just after geting the socket in my incomingConnection slot it works fine. 如果我在我的客户端中使用connectToHostEncrypted()
在将我的ConnectionConnection插槽中的套接字获取后立即调用startServerEncryption()
,则它可以正常工作。 startServerEncryption()
, I got the error : Error during SSL handshake: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
on server side. 但是,如果我延迟握手(通过在套接字中进行一些读/写操作)并稍后调用startServerEncryption()
, Error during SSL handshake: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
收到错误: Error during SSL handshake: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
服务器端Error during SSL handshake: error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
。 I've also tried to use startClientEncryption()
on client side but I get the same error. 我也尝试在客户端上使用startClientEncryption()
,但出现相同的错误。 The certificate is self-signed and loaded and applied to the socket correctly on server (I checked by testing the first situation with openssl s_client and the server accept all the protocol that I can test with (SSLv3, TLSv1, TLSv1.1, TLSv1.2).I cannot test with SSLv2 : on the Client, using this protocol with QSslSocket::setProtocol(QSsl::SslV2)
show the error unsupported protocol
and openssl s_client won't connect with the -ssl2 argument, it just show the available arguments. 证书是自签名的,并已正确加载到服务器上的套接字中(我通过使用openssl s_client测试第一种情况进行了检查,并且服务器接受了可以测试的所有协议(SSLv3,TLSv1,TLSv1.1,TLSv1。 2)。我无法使用SSLv2进行测试:在客户端上,将此协议与QSslSocket::setProtocol(QSsl::SslV2)
显示错误的unsupported protocol
,openssl s_client不会与-ssl2参数连接,它只会显示可用的论点。
I'm using Qt 5.9.1 and I've installed OpenSSL-Win32 v1.0.2L to get the dlls. 我正在使用Qt 5.9.1,并且已经安装了OpenSSL-Win32 v1.0.2L以获取dll。 I'm also compiling with msvc2015 32bit on Windows 7 64bit. 我还在Windows 7 64bit上使用msvc2015 32bit进行编译。 I hope that you can help me (and sorry for my bad english), Nicolas. 尼古拉斯,我希望你能帮助我(对不起我的英语不好)。
I've just found my error : I was using a readyRead slot which was using socket->readAll()
and that prevented the SSL handshake ! 我刚发现我的错误:我正在使用一个readyRead插槽,该插槽正在使用socket->readAll()
,并且阻止了SSL握手! I've also discovered that you need to call both startClientEncryption and startServerEncryption to make a SSL handshake. 我还发现,您需要同时调用startClientEncryption和startServerEncryption来进行SSL握手。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.