<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#333333">
    Hi All,<br>
    <br>
    I am using OpenSSL 1.0.1l<span style="color: rgb(0, 0, 0);
      font-family: 'Times New Roman'; font-size: medium; font-style:
      normal; font-variant: normal; font-weight: normal; letter-spacing:
      normal; line-height: normal; orphans: auto; text-align: start;
      text-indent: 0px; text-transform: none; white-space: normal;
      widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;
      display: inline !important; float: none; background-color:
      rgb(240, 240, 240);"><span class="Apple-converted-space"></span></span>  
    in Win32 environment.  At the beginning of my program I call<br>
    <br>
        SSL_library_init();<br>
        SSL_load_error_strings();<br>
    <br>
    Those functions are only called once.<br>
    <br>
    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).<br>
    <br>
    SSL_CTX_new<br>
    SSL_CTX_set_verify<br>
    SSL_CTX_set_cert_verify_callback<br>
    BIO_new_connect<br>
    BIO_do_connect<br>
    SSL_new<br>
    SSL_set_bio<br>
    SSL_get_peer_certificate<br>
    SSL_write<br>
    SSL_read<br>
    SSL_get_error<br>
    <br>
    <br>
    (cleanup functions.. if conditions used to prevent double frees,
    etc.)<br>
    X509_free<br>
    SSL_shutdown<br>
    SSL_free<br>
    BIO_free<br>
    SSL_CTX_free<br>
    <br>
    <br>
    <br>
    <br>
    My questions are the following:<br>
    <br>
    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?<br>
    2)  Should I be doing any other cleanup functions within the
    threads?<br>
    <br>
    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<br>
    <br>
    Handle leaks<br>
    <br>
    _shmem_winpthreads_grab<br>
    _pthread_register_pointer<br>
    <br>
    In fact I get memory leaks reported if I just do   
    SSL_library_init(); alone<br>
    <br>
    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.<br>
    <br>
    Should I be doing any other cleanup operations?<br>
    <br>
    Thanks for the assistance.<br>
    <br>
    Best Regards,<br>
    <br>
    -Avery T.<br>
  </body>
</html>