From 6ab5d42c92ab55a6ea59d442d6c6a01e8282bbc6 Mon Sep 17 00:00:00 2001 From: Mats Klepsland Date: Mon, 7 Aug 2017 09:53:25 +0200 Subject: [PATCH] unittests: initialize NSS in unittests runmode Initialize NSS in unittests runmode when Suricata is compiled with libnss. Otherwise, calculating SHA-1 sums for TLS fingerprints will fail. --- src/runmode-unittests.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/runmode-unittests.c b/src/runmode-unittests.c index daceaf12ea..7a99aa93fd 100644 --- a/src/runmode-unittests.c +++ b/src/runmode-unittests.c @@ -122,6 +122,11 @@ #include "util-streaming-buffer.h" #include "util-lua.h" +#ifdef HAVE_NSS +#include +#include +#endif + #endif /* UNITTESTS */ void TmqhSetup (void); @@ -283,6 +288,13 @@ void RunUnittests(int list_unittests, const char *regex_arg) UtRunSelftest(regex_arg); /* inits and cleans up again */ } +#ifdef HAVE_NSS + /* init NSS for hashing */ + PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0); + NSS_NoDB_Init(NULL); +#endif + + AppLayerHtpEnableRequestBodyCallback(); AppLayerHtpNeedFileInspection();