Free tls resources on exit too

svn:r3615
This commit is contained in:
Nick Mathewson 2005-02-11 01:41:19 +00:00
parent f672577bc6
commit 5d836c8140
3 changed files with 13 additions and 0 deletions

View File

@ -156,6 +156,17 @@ tor_tls_init(void) {
} }
} }
void
tor_tls_free_all(void)
{
if (global_tls_context) {
SSL_CTX_free(global_tls_context->ctx);
SSL_CTX_free(global_tls_context->client_only_ctx);
tor_free(global_tls_context);
global_tls_context = NULL;
}
}
/** We need to give OpenSSL a callback to verify certificates. This is /** We need to give OpenSSL a callback to verify certificates. This is
* it: We always accept peer certs and complete the handshake. We * it: We always accept peer certs and complete the handshake. We
* don't validate them until later. * don't validate them until later.

View File

@ -24,6 +24,7 @@ typedef struct tor_tls_st tor_tls;
#define TOR_TLS_WANTWRITE -1 #define TOR_TLS_WANTWRITE -1
#define TOR_TLS_DONE 0 #define TOR_TLS_DONE 0
void tor_tls_free_all(void);
int tor_tls_context_new(crypto_pk_env_t *rsa, int isServer, int tor_tls_context_new(crypto_pk_env_t *rsa, int isServer,
const char *nickname, unsigned int key_lifetime); const char *nickname, unsigned int key_lifetime);
tor_tls *tor_tls_new(int sock, int is_server, int use_no_cert); tor_tls *tor_tls_new(int sock, int is_server, int use_no_cert);

View File

@ -1320,6 +1320,7 @@ void tor_free_all(void)
connection_free_all(); connection_free_all();
config_free_all(); config_free_all();
router_free_all_keys(); router_free_all_keys();
tor_tls_free_all();
/* stuff in main.c */ /* stuff in main.c */
smartlist_free(closeable_connection_lst); smartlist_free(closeable_connection_lst);
} }