You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by dm...@apache.org on 2021/11/23 10:23:06 UTC

[trafficserver] branch master updated: Destroy ssl context after use. (#8531)

This is an automated email from the ASF dual-hosted git repository.

dmeden pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new 57015b7  Destroy ssl context after use. (#8531)
57015b7 is described below

commit 57015b77d45acc7bccea5295a26168faa1d6ef52
Author: Damian Meden <da...@gmail.com>
AuthorDate: Tue Nov 23 10:22:49 2021 +0000

    Destroy ssl context after use. (#8531)
    
    As per the docs this needs to be released after use, this was missing from the cert_reporting_tool plugin.
    This also fixes the example in the docs.
---
 doc/developer-guide/api/functions/TSSslClientContext.en.rst     | 7 ++++++-
 plugins/experimental/cert_reporting_tool/cert_reporting_tool.cc | 5 +++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/doc/developer-guide/api/functions/TSSslClientContext.en.rst b/doc/developer-guide/api/functions/TSSslClientContext.en.rst
index ca14c17..25cc070 100644
--- a/doc/developer-guide/api/functions/TSSslClientContext.en.rst
+++ b/doc/developer-guide/api/functions/TSSslClientContext.en.rst
@@ -59,4 +59,9 @@ Server source distribution. It demonstrates how to use :func:`TSSslClientContext
 
 .. literalinclude:: ../../../../example/plugins/c-api/client_context_dump/client_context_dump.cc
   :language: c
-  :lines: 137-145
+  :lines: 154-166
+
+
+.. literalinclude:: ../../../../example/plugins/c-api/client_context_dump/client_context_dump.cc
+  :language: c
+  :lines: 51-55
diff --git a/plugins/experimental/cert_reporting_tool/cert_reporting_tool.cc b/plugins/experimental/cert_reporting_tool/cert_reporting_tool.cc
index fd6ab40..263b90d 100644
--- a/plugins/experimental/cert_reporting_tool/cert_reporting_tool.cc
+++ b/plugins/experimental/cert_reporting_tool/cert_reporting_tool.cc
@@ -51,9 +51,9 @@ asn1_string_extract(ASN1_STRING *s)
 void
 dump_context(const char *ca_path, const char *ck_path)
 {
-  SSL_CTX *ctx = reinterpret_cast<SSL_CTX *>(TSSslClientContextFindByName(ca_path, ck_path));
+  TSSslContext ctx = TSSslClientContextFindByName(ca_path, ck_path);
   if (ctx) {
-    SSL *s = SSL_new(ctx);
+    SSL *s = SSL_new(reinterpret_cast<SSL_CTX *>(ctx));
     if (s) {
       char *data  = nullptr;
       long length = 0;
@@ -137,6 +137,7 @@ dump_context(const char *ca_path, const char *ck_path)
       }
     }
     SSL_free(s);
+    TSSslContextDestroy(ctx);
   }
 }