summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-05-13 07:54:28 +0300
committerLars Wirzenius <liw@liw.fi>2020-05-13 08:57:51 +0300
commitd32125b1bfcd360d70b68a2db5942848ac6c6dcf (patch)
tree678dbdbcf46d2203efef0701bccf7de78c067165
parent3ef0cf4ebff0b2598fd82112c9c6e09ffff9bfa6 (diff)
downloadewww-d32125b1bfcd360d70b68a2db5942848ac6c6dcf.tar.gz
test: create a self-signed certificate for testing
-rwxr-xr-xcheck2
-rwxr-xr-xmktestcert13
2 files changed, 15 insertions, 0 deletions
diff --git a/check b/check
index 8e39fde..8d7e56e 100755
--- a/check
+++ b/check
@@ -40,6 +40,8 @@ then
fi
$hideok cargo test $quiet
+$hideok ./mktestcert test.key test.pem hunter2
+
for md in [^R]*.md
do
$hideok echo "$md ====================================="
diff --git a/mktestcert b/mktestcert
new file mode 100755
index 0000000..bb092d7
--- /dev/null
+++ b/mktestcert
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+set -eu
+
+key="$1"
+cert="$2"
+csr="$(mktemp)"
+
+openssl genrsa -out "$key" 2048
+openssl rsa -in "$key" -out "$key"
+openssl req -sha256 -new -key "$key" -out "$csr" -subj '/CN=localhost'
+openssl x509 -req -sha256 -days 365 -in "$csr" -signkey "$key" -out "$cert"
+rm -f "$csr"