tests: add preflight TLS script

This commit is contained in:
Nathaniel Wesley Filardo 2021-12-30 08:12:28 +00:00
parent 74554ddd47
commit 219b11698c
1 changed files with 21 additions and 0 deletions

21
tests/preflight-tls.sh Normal file
View File

@ -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"
}