简体   繁体   English

使用 Boost ASIO 和 SSL (C++) 时出现“版本号错误”错误

[英]"Wrong Version Number" error using Boost ASIO & SSL (C++)

I'm trying to connect to a server (written in Golang) using Boost Asio.我正在尝试使用 Boost Asio 连接到服务器(用 Golang 编写)。 I can connect and read/write fine unencrypted, but I can't seem to get SSL support to work.我可以在未加密的情况下正常连接和读/写,但我似乎无法获得 SSL 支持。 Basically, whenever I attempt a handshake I receive a "wrong version number".基本上,每当我尝试握手时,我都会收到“错误的版本号”。

Here's a snippet that shows how I'm trying to set it up.这是一个片段,显示了我是如何尝试设置它的。 I'm not trying to perform any verification, just get the connection going.我不想执行任何验证,只是让连接继续。 At this point in the code, the client has connected to the server and swapped some unencrypted commands.在代码的这一点上,客户端已经连接到服务器并交换了一些未加密的命令。

boost::asio::ssl::context ctx(*ios, boost::asio::ssl::context::tlsv12_client);  //also tried sslv23, etc
ctx.set_verify_mode(boost::asio::ssl::context::verify_none);
this->sslSocket = new boost::asio::ssl::stream<boost::asio::ip::tcp::socket&>(*socket, ctx);  
this->sslSocket->async_handshake(boost::asio::ssl::stream_base::client,
            boost::bind(&MyConnection::handleHandshake, this,
            boost::asio::placeholders::error));

&MyConnection::handleHandshake() receives the result of the handshake. &MyConnection::handleHandshake()接收握手的结果。

So questions are:所以问题是:

  • Is the above code doing everything it should normally need to do to connect to a server?上面的代码是否完成了连接到服务器通常需要做的所有事情? Am I missing a step?我错过了一步吗?
  • Are there server side issues that might be in play?是否存在可能在起作用的服务器端问题? I checked throught the Go code, and it does look to support TLS 1.0/1.1/1.2 as well as SSL 2 & 3我检查了 Go 代码,它确实支持 TLS 1.0/1.1/1.2 以及 SSL 2 和 3

I faced the same problem, later came to know I was trying to connect to port 80 instead of 443 (SSL port).我遇到了同样的问题,后来才知道我正在尝试连接到端口 80 而不是 443(SSL 端口)。 By changing the port to 443, issue got resolved.通过将端口更改为 443,问题得到解决。

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

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