提高:: ASIO转换插座,以确保 [英] boost::asio convert socket to secure

查看:168
本文介绍了提高:: ASIO转换插座,以确保的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写在C ++游戏的Minecraft的服务器。

I'm writing a server for the game Minecraft in C++.

客户端通过一正常的套接发送初始握手报文给服务器。然后,服务器发送一个RSA密钥回从该点起变成AES加密,发送到客户端RSA密钥游戏和所有套接字通信。

The client sends an initial handshake packet to the server through a normal socket. The server then sends an RSA key back to the game and all socket communication from that point onwards becomes AES encrypted with the RSA key sent to the client.

我有一个想法,我能避免实施AES / RSA和服务器后直接通过简单地改变我的正常升压链接到我的服务器的其他库:: ASIO插座变成一个boost :: ASIO SSL套接字发送RSA密钥来客户端

I had an idea that I could avoid implementing AES/RSA and linking to other libraries in my server by simply transforming my regular boost::asio socket into a boost::asio ssl socket directly after the server sends the RSA key to the client.

我如何,如果是已经创建它转换插座?

How can I transform the socket if it's already been created?

推荐答案

SSL ::流是在 TCP之上实现::插座,你可以直接通过 next_layer lowest_layer 成员函数访问套接字。事实上,使用 SSL ::流,你先连接插座强调,然后调用 SSL ::流::握手。注意,你可以做任何你想要在这两个步骤,喜欢阅读,并从 TCP套接字:: 直接写入。请参见这个例子的详细信息

ssl::stream is implemented on top of a tcp::socket, and you can access the socket directly through the next_layer or lowest_layer member functions. In fact, to use the ssl::stream, you first connect the underlining socket and then invoke ssl::stream::handshake. Note that you can do whatever you want between these two steps, like reading and writing from that tcp::socket directly. See this example for details.

这篇关于提高:: ASIO转换插座,以确保的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆