From: Eric Leblond Date: Fri, 6 Mar 2015 18:55:28 +0000 (+0100) Subject: json-tls: refactor to export logging function X-Git-Tag: suricata-2.1beta4~178 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=22182e7a8430626753b4903db9705b8359a08904;p=thirdparty%2Fsuricata.git 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. --- 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__ */