模仿 socket.h 的 OpenSSL 包装器 (C++)
我正在处理这个大型自定义网络应用程序。它是用 C++ (linux) 编写的,使用 sockets.h --- 代码涉及传递文件(套接字)描述符、使用结构、设置套接字选项等。
而不是全部重写,我想知道是否有任何可用的东西,使用与socket.h相同的函数原型,但使用openSSL来保护通信通道。
显然,人们仍然需要设置诸如密钥、验证位置等内容,但最好避免将所有内容更改为 BIO 或其他内容......
谢谢!
I'm dealing with this large custom networking app. It was written in C++ (linux), using sockets.h --- the code involves passing around file(socket) descriptors, uses the structs, sets socket options, etc, etc.
Rather than rewriting it all, was wondering if there was anything available that uses the same function prototypes as socket.h, but uses openSSL to protect the comms channel.
Obviously, one still needs to set things such as the keys, verify locations, etc, but it would be great to avoid changing everything to BIOs or whatever...
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SSL_set_fd 和 SSL_get_fd 让您设置/检索文件描述符并避免 BIO。您仍然需要使用 SSL_read/SSL_write 而不是读/写,等等。
要实现 sockets.h 接口,需要一种轻松从 fd 转到 SSL 对象的方法,这并不简单。 OpenSSL 没有附带这样的包装器,而且我非常怀疑是否存在第三方包装器。
SSL_set_fd and SSL_get_fd let you set/retrieve file descriptor and avoid BIOs. You still need to use SSL_read/SSL_write instead of read/write, and so on.
To implement the sockets.h interface would require a way to easily go from the fd to the SSL object, which is non-trivial. No such wrapper comes with OpenSSL, and I highly doubt a third-party wrapper exists either.