]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
json-tls: refactor to export logging function
authorEric Leblond <eric@regit.org>
Fri, 6 Mar 2015 18:55:28 +0000 (19:55 +0100)
committerEric Leblond <eric@regit.org>
Fri, 6 Mar 2015 19:16:26 +0000 (20:16 +0100)
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
src/output-json-tls.h

index 129b8177bf31e043a563307baac163b1c3cb31e1..f2843e49fedd4bd87ec5882b6c3d7e2ae48a2ec5 100644 (file)
@@ -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);
index 931414f3013b7a2d99b93d2bedef9a352a2ec3ee..f330ad898aad2d138776493b7043ab4ce35527e7 100644 (file)
 
 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__ */