Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An OpenSSL wrapper that mimics socket.h (C++)

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!!

like image 239
Jzao Avatar asked Nov 13 '22 15:11

Jzao


1 Answers

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.

like image 134
Jumbogram Avatar answered Dec 27 '22 05:12

Jumbogram