[openssl-users] Encryption/decryption using parameters obtained via handshake (SSL_accept/SSL_connect)

vgt tkachyov at mailfrom.ru
Sat Jan 16 04:11:33 UTC 2016

Hello, all :)

I need to link OpenSSL to a library which makes reads/writes itself and
permits only to encrypt data before sending (and decrypt after
receiving). Is it possible to initialize connection as follows

context = SSL_CTX_new(SSLv23_method());
if(!SSL_CTX_use_certificate_file(context, certFile,
if(SSL_CTX_use_PrivateKey_file(context, keyFile, SSL_FILETYPE_PEM)<0
) ...
ssl = SSL_new(context);
SSL_set_fd(ssl,fd); /// fd is an open socket descriptor
SSL_accept(ssl); // or SSL_connect(ssl); in client

and then use encryption/decryption using parameters obtained by the
initialization stage above?

Thank you in advance, Vladimir

P.S. SSL_read/SSL_write then works well, but as I mentioned, the library
does reads/writes itself...

More information about the openssl-users mailing list