I wrote a little test program to speak HTTP over SSL (so called
HTTPS ;-). The code (nicely formatted and commented for easy reading),
valgrind output and all necessary information can be found here[0].

This small app is leaking memory when it runs from start to finish
without any errors (the error handling is kept simple for the example).
Because there's no memory allocation in my code I guess I forgot to
call some cleaning functions. The problem is the documentation isn't
saying too much about what function internally allocates memory blocks
and what call frees them.

Here are schematically the calls in used order:

,-----
| SSL_library_init();
| 
| SSL_load_error_strings();
| ERR_load_BIO_strings();
| 
| pSSLMeth = SSLv3_client_method()
| pCtx     = SSL_CTX_new(pSSLMeth)
| 
| SSL_CTX_use_certificate_chain_file(pCtx, "client.crt")
| SSL_CTX_use_PrivateKey_file(pCtx, "client.key", SSL_FILETYPE_PEM)
| SSL_CTX_check_private_key(pCtx)
| SSL_CTX_load_verify_locations(pCtx, "ca.crt", NULL))
|       
| pBio = BIO_new_buffer_ssl_connect(pCtx)
| 
| BIO_get_ssl(pBio, &pSsl);
| SSL_set_mode(pSsl, SSL_MODE_AUTO_RETRY);
| BIO_set_conn_hostname(pBio, HOSTNAME);
| BIO_set_conn_port(pBio, HTTPS_PORT);
| BIO_do_connect(pBio)
| 
| SSL_CTX_set_verify(pCtx, VERIFY_SWITCHES, NULL);
| SSL_CTX_set_verify_depth(pCtx, 1);
| SSL_get_verify_result(pSsl)
| 
| BIO_write(pBio, REQUEST, sizeof(REQUEST));
| BIO_flush(pBio)
| BIO_gets(pBio, buffer, 4096);
| 
| SSL_CTX_free(pCtx);
| BIO_free_all(pBio);
| ERR_free_strings();
`-----

What else do I have to free?

regards,
Lars

[0] http://lars-uhlmann.de/misc/openssl/
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to