From ab12384e1442eb6f78d3331399e44f4fb2016e50 Mon Sep 17 00:00:00 2001 From: Damian Meden Date: Fri, 19 Nov 2021 15:12:15 +0000 Subject: [PATCH] Destroy ssl context after use. 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. --- .../api/functions/TSSslClientContext.en.rst | 7 ++++++- .../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 ca14c17b11c..25cc070d76f 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 fd6ab40b5d9..263b90defd9 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(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(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); } }