Browse Source

Free tls resources on exit too

svn:r3615
Nick Mathewson 19 years ago
parent
commit
5d836c8140
3 changed files with 13 additions and 0 deletions
  1. 11 0
      src/common/tortls.c
  2. 1 0
      src/common/tortls.h
  3. 1 0
      src/or/main.c

+ 11 - 0
src/common/tortls.c

@@ -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
  * it: We always accept peer certs and complete the handshake.  We
  * don't validate them until later.

+ 1 - 0
src/common/tortls.h

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

+ 1 - 0
src/or/main.c

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