[openssl-users] Proper cleanup functions being called?

Avery A. Tarasov Avery.A.Tarasov at SecurityEngineer.Pro
Thu Jan 22 05:36:08 UTC 2015


Hi All,

I am using OpenSSL 1.0.1lin Win32 environment.  At the beginning of my 
program I call

     SSL_library_init();
     SSL_load_error_strings();

Those functions are only called once.

Then I have 3 threads which can't possibly be run at the same time due 
to mutexes I'm setting with WaitForSingleObject and ReleaseMutex.  Those 
3 threads use these functions below and all variables in those threads 
are local to the threads (e.g. no globals).

SSL_CTX_new
SSL_CTX_set_verify
SSL_CTX_set_cert_verify_callback
BIO_new_connect
BIO_do_connect
SSL_new
SSL_set_bio
SSL_get_peer_certificate
SSL_write
SSL_read
SSL_get_error


(cleanup functions.. if conditions used to prevent double frees, etc.)
X509_free
SSL_shutdown
SSL_free
BIO_free
SSL_CTX_free




My questions are the following:

1)  Am I correct that I only need to call the SSL_library_init(); and 
SSL_load_error_strings();  once at the beginning of the program , and 
not at the beginning of each thread?
2)  Should I be doing any other cleanup functions within the threads?

My program appears to work perfectly but a tool is complaining about 
memory leaks in _CRYPTO_malloc, _asn1_enc_save,  _asn1_item_ex_d2i, 
_d2i_X509

Handle leaks

_shmem_winpthreads_grab
_pthread_register_pointer

In fact I get memory leaks reported if I just do SSL_library_init(); alone

Despite the reports of the leaks my program seems to run fine for days 
and stay consistent in memory used.  But I'm feeling paranoid something 
just isn't quite right.

Should I be doing any other cleanup operations?

Thanks for the assistance.

Best Regards,

-Avery T.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mta.openssl.org/pipermail/openssl-users/attachments/20150122/a11c2d02/attachment.html>


More information about the openssl-users mailing list