Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting to use OpenSSL

Tags:

ssl

openssl

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 documentation trying to figure out how to use the library.

Do you have any resources or simple programs or tutorials that will walk me through integrating OpenSSL with my program?

like image 579
VSC Avatar asked Jan 25 '26 21:01

VSC


2 Answers

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.

like image 161
caf Avatar answered Jan 27 '26 12:01

caf


You can find some useful OpenSSL commands on this page:

http://www.networking4all.com/en/support/ssl+certificates/manuals/openssl/openssl+commands/

like image 40
Paul Avatar answered Jan 27 '26 13:01

Paul



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!