Skip to content

SpiderFoot automates OSINT for threat intelligence and mapping your attack surface.

generate-certificate: add validation

Brendan Coles6d1c101ffb41
diff --git a/generate-certificate b/generate-certificate
index 003816c9..ffb6b4a4 100755
--- a/generate-certificate
+++ b/generate-certificate
@@ -1,4 +1,20 @@
#!/bin/sh
+if ! command -v openssl >/dev/null 2>&1 ; then
+ echo "Error: Could not find openssl in \$PATH: $PATH"
+ exit 1
+fi
+
+if test -f spiderfoot.key; then
+ echo "Error: spiderfoot.key already exists"
+ exit 1
+fi
+
+if test -f spiderfoot.crt; then
+ echo "Error: spiderfoot.crt already exists"
+ exit 1
+fi
+
openssl req -new -newkey rsa:4096 -sha256 -x509 -days 365 -nodes -out spiderfoot.crt -keyout spiderfoot.key -subj "/CN=localhost"
+
chmod 600 spiderfoot.crt
chmod 600 spiderfoot.key