Starting to use OpenSSL

前端 未结 3 1715
终归单人心
终归单人心 2021-01-01 07:14

I want to use SSL in my cross platform program. I decided to use OpenSSL.

I have OpenSSL installed, and at this point I am looking through the code and documentatio

3条回答
  •  一个人的身影
    2021-01-01 07:42

    The very rough guide is:

    • Create a new SSL_CTX with SSL_CTX_new();
    • (server only) Load the certificate with SSL_CTX_use_certificate_file();
    • (server only) Load the private key with SSL_CTX_use_PrivateKey_file();
    • Establish the network connection;
    • Create a new SSL with SSL_new();
    • Set the file descriptor of the SSL to that of your network connection with SSL_set_fd();
    • (client only) Call SSL_connect();
    • (server only) Call SSL_accept().

    Thereafter use SSL_read() and SSL_write() to read and write from the connection, and finish with SSL_shutdown(). The SSL_CTX can be re-used to create SSL objects for many simultaneous sessions.

提交回复
热议问题