From 22182e7a8430626753b4903db9705b8359a08904 Mon Sep 17 00:00:00 2001 From: Eric Leblond Date: Fri, 6 Mar 2015 19:55:28 +0100 Subject: [PATCH] json-tls: refactor to export logging function To be able to add TLS data in alert we need to do the same as what is done with HTTP ie export the logging functions. --- src/output-json-tls.c | 24 +++++++++++++++--------- src/output-json-tls.h | 7 +++++++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/output-json-tls.c b/src/output-json-tls.c index 129b8177bf..f2843e49fe 100644 --- a/src/output-json-tls.c +++ b/src/output-json-tls.c @@ -72,7 +72,19 @@ typedef struct JsonTlsLogThread_ { #define SSL_VERSION_LENGTH 13 -static void LogTlsLogExtendedJSON(json_t *tjs, SSLState * state) +void JsonTlsLogJSONBasic(json_t *js, SSLState *ssl_state) +{ + /* tls.subject */ + json_object_set_new(js, "subject", + json_string(ssl_state->server_connp.cert0_subject)); + + /* tls.issuerdn */ + json_object_set_new(js, "issuerdn", + json_string(ssl_state->server_connp.cert0_issuerdn)); + +} + +void JsonTlsLogJSONExtended(json_t *tjs, SSLState * state) { char ssl_version[SSL_VERSION_LENGTH + 1]; @@ -145,16 +157,10 @@ static int JsonTlsLogger(ThreadVars *tv, void *thread_data, const Packet *p) /* reset */ MemBufferReset(buffer); - /* tls.subject */ - json_object_set_new(tjs, "subject", - json_string(ssl_state->server_connp.cert0_subject)); - - /* tls.issuerdn */ - json_object_set_new(tjs, "issuerdn", - json_string(ssl_state->server_connp.cert0_issuerdn)); + JsonTlsLogJSONBasic(tjs, ssl_state); if (tls_ctx->flags & LOG_TLS_EXTENDED) { - LogTlsLogExtendedJSON(tjs, ssl_state); + JsonTlsLogJSONExtended(tjs, ssl_state); } json_object_set_new(js, "tls", tjs); diff --git a/src/output-json-tls.h b/src/output-json-tls.h index 931414f301..f330ad898a 100644 --- a/src/output-json-tls.h +++ b/src/output-json-tls.h @@ -26,4 +26,11 @@ void TmModuleJsonTlsLogRegister (void); +#ifdef HAVE_LIBJANSSON +#include "app-layer-ssl.h" + +void JsonTlsLogJSONBasic(json_t *js, SSLState *ssl_state); +void JsonTlsLogJSONExtended(json_t *js, SSLState *ssl_state); +#endif /* HAVE_LIBJANSSON */ + #endif /* __OUTPUT_JSON_TLS_H__ */ -- 2.47.3