From 219b11698cdc9b3d9a547d48ed46964614550788 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Thu, 30 Dec 2021 08:12:28 +0000 Subject: [PATCH] tests: add preflight TLS script --- tests/preflight-tls.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/preflight-tls.sh diff --git a/tests/preflight-tls.sh b/tests/preflight-tls.sh new file mode 100644 index 00000000..618a59ab --- /dev/null +++ b/tests/preflight-tls.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +set -e -u + +genectls() { + openssl ecparam -genkey -name "${1}" -out "${2}.key" + openssl req -new -sha256 -subj "/CN=${1}" -key "${2}.key" -out "${2}.csr" + openssl req -x509 -sha256 -days 365 -key "${2}.key" -in "${2}.csr" -out "${2}.crt" +} + +PFX="${NODEMCU_TESTTMP}/tmp-ec256v1" +[ -r "${PFX}.key" ] || genectls "prime256v1" "${PFX}" + +PFX="${NODEMCU_TESTTMP}/tmp-ec384r1" +[ -r "${PFX}.key" ] || genectls "secp384r1" "${PFX}" + +PFX="${NODEMCU_TESTTMP}/tmp-rsa2048" +[ -r "${PFX}.key" ] || { + openssl genrsa -out "${PFX}.key" "2048" + openssl req -x509 -nodes -subj "/CN=rsa" -key "${PFX}.key" -out "${PFX}.crt" "-days" "365" +}