]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Refactored key_state free code
authorAdriaan de Jong <dejong@fox-it.com>
Mon, 27 Jun 2011 15:51:23 +0000 (17:51 +0200)
committerDavid Sommerseth <davids@redhat.com>
Fri, 21 Oct 2011 08:53:32 +0000 (10:53 +0200)
Signed-off-by: Adriaan de Jong <dejong@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Signed-off-by: David Sommerseth <davids@redhat.com>
ssl.c
ssl_backend.h
ssl_openssl.c

diff --git a/ssl.c b/ssl.c
index ae9d36c573cb194a77ca11d1848e7c390ba89184..5b6a5cac6d3dbb6c055aca55b6cd13042c11c850 100644 (file)
--- a/ssl.c
+++ b/ssl.c
@@ -2262,15 +2262,7 @@ key_state_free (struct key_state *ks, bool clear)
 {
   ks->state = S_UNDEF;
 
-  if (ks->ks_ssl.ssl) {
-#ifdef BIO_DEBUG
-    bio_debug_oc ("close ssl_bio", ks->ks_ssl.ssl_bio);
-    bio_debug_oc ("close ct_in", ks->ks_ssl.ct_in);
-    bio_debug_oc ("close ct_out", ks->ks_ssl.ct_out);
-#endif
-    BIO_free_all(ks->ks_ssl.ssl_bio);
-    SSL_free (ks->ks_ssl.ssl);
-  }
+  key_state_ssl_free(&ks->ks_ssl);
 
   free_key_ctx_bi (&ks->key);
   free_buf (&ks->plaintext_read_buf);
index 5c96dafed1fa013bf10d604d4f521971176ab444..22266520e6cffa725ab340776313b9e1d5df7f5d 100644 (file)
@@ -287,6 +287,13 @@ void tls_ctx_load_extra_certs (struct tls_root_ctx *ctx, const char *extra_certs
 void key_state_ssl_init(struct key_state_ssl *ks_ssl,
     const struct tls_root_ctx *ssl_ctx, bool is_server, void *session);
 
+/**
+ * Free the SSL channel part of the given key state.
+ *
+ * @param ks_ssl       The SSL channel's state info to free
+ */
+void key_state_ssl_free(struct key_state_ssl *ks_ssl);
+
 /*
  * Show the TLS ciphers that are available for us to use in the OpenSSL
  * library.
index 1214c6eadcfb49421f392b0508748253fb22a922..8c3c4552f9ada89f162c4c5a9c9e8b0a65609ddd 100644 (file)
@@ -889,6 +889,19 @@ key_state_ssl_init(struct key_state_ssl *ks_ssl, const struct tls_root_ctx *ssl_
   BIO_set_ssl (ks_ssl->ssl_bio, ks_ssl->ssl, BIO_NOCLOSE);
 }
 
+void key_state_ssl_free(struct key_state_ssl *ks_ssl)
+{
+  if (ks_ssl->ssl) {
+#ifdef BIO_DEBUG
+    bio_debug_oc ("close ssl_bio", ks_ssl->ssl_bio);
+    bio_debug_oc ("close ct_in", ks_ssl->ct_in);
+    bio_debug_oc ("close ct_out", ks_ssl->ct_out);
+#endif
+    BIO_free_all(ks_ssl->ssl_bio);
+    SSL_free (ks_ssl->ssl);
+  }
+}
+
 void
 tls_ctx_load_extra_certs (struct tls_root_ctx *ctx, const char *extra_certs_file
 #if ENABLE_INLINE_FILES