Coder Social home page Coder Social logo

alongl / openssl_for_muduo Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 6.0 5.23 MB

A sample to show how to add openssl support for muduo. It's the same for other networking library.

Makefile 0.16% C++ 97.63% C 0.03% Starlark 0.59% CMake 1.59%
muduo openssl ssl-bio openssl-support cpp

openssl_for_muduo's Introduction

openssl_for_muduo client and server sample

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.

How To Use?

  1. download and compile muduo library from http://github.com/chenshuo/muduo
  2. modify the Makefile to find muduo library (muduo is provided in this project. It's compiled in centos7)
  3. install openssl
    for centos: yum install openssl-devel
    for ubuntu: apt install openssl libssl-dev -y
  4. type make to compile this client.cpp
  5. sslclient and sslserver will be generated in the folder
  6. you can run sslserver and access https://localhost:1443/ with web broswer to see the result.

Core tech

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.

  1. use SSL_is_init_finished() to judge the handshake is ok.
  2. when you want to recv data :
    BIO_write and SSL_read
  3. when you want to send data:
    SSL_write and BIO_read

More

  • This code is a demo. The best method to use ssl is to implement SSL-TcpConnection to handle data receive and send.

Reference:

  1. https://github.com/my-official/IOCP_SSL
  2. https://blog.csdn.net/xiaoqing_2014/article/details/79720913

openssl_for_muduo's People

Contributors

alongl avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.