Muduo is a multithreaded C++ network library based on the reactor pattern.
http://github.com/chenshuo/muduo
But I didn't found there is openssl support. This is a client and server sample use SSL_BIO base muduo. This is a good sample for reactor networking library to use openssl. You can easily modify it to adapt other networking library. If you want to learn more about openssl in server side, please see references.
- download and compile muduo library from http://github.com/chenshuo/muduo
- modify the Makefile to find muduo library (muduo is provided in this project. It's compiled in centos7)
- install openssl
for centos: yum install openssl-devel
for ubuntu: apt install openssl libssl-dev -y - type make to compile this client.cpp
- sslclient and sslserver will be generated in the folder
- you can run sslserver and access https://localhost:1443/ with web broswer to see the result.
Usually openssl is implemented only by SSL_read and SSL_write like
https://github.com/yedf/openssl-example
This will use openssl to read and write socket.
In some case, the data is received by networking library, the user program can just use the data already received by networking lib, maybe you can try SSL_BIO to implement ssl socket.
- use SSL_is_init_finished() to judge the handshake is ok.
- when you want to recv data :
BIO_write and SSL_read - when you want to send data:
SSL_write and BIO_read
- This code is a demo. The best method to use ssl is to implement SSL-TcpConnection to handle data receive and send.