X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=commonFunctions;h=8b12bf43a3de730cae46440ffeb22cb2fb8bde43;hb=333f02148290de089bd59cbdc2f8ac7e50b3ee66;hp=5e1ffbf2929b40210e5ed3fb6ed98b2c56e17d97;hpb=2d5c169f43c88c0abedf60990b1fd622e8261b49;p=nre.git diff --git a/commonFunctions b/commonFunctions index 5e1ffbf..8b12bf4 100755 --- a/commonFunctions +++ b/commonFunctions @@ -1,3 +1,4 @@ +#!/bin/bash . structure genKey(){ #subj, internalName @@ -21,14 +22,19 @@ genca(){ #subj, internalName caSign(){ # csr,ca,config,start,end start="$4" end="$5" - [ "$start" != "" ] && start="-startdate $start" - [ "$end" != "" ] && end="-enddate $end" - [ "$start" == "" -a "$end" == "" ] && start="-days 366" + [[ "$start" != "" ]] && start="-startdate $start" + [[ "$end" != "" ]] && end="-enddate $end" + [[ "$start" == "" && "$end" == "" ]] && start="$ROOT_VALIDITY" BASE="$PWD" echo "Signing: $1 with $2" echo "$start $end" pushd $2.ca > /dev/null - openssl ca -cert key.crt -keyfile key.key -in "$BASE/$1.csr" -out "$BASE/$1.crt" -batch -config "$BASE/selfsign.config" -extfile "$BASE/$3" $start $end + if [[ "$2" == "root" && "$1" == root.* ]]; then + signkey="-selfsign" + else + signkey="-cert key.crt" + fi + openssl ca $signkey -keyfile key.key -in "$BASE/$1.csr" -out "$BASE/$1.crt" -batch -config "$BASE/selfsign.config" -extfile "$BASE/$3" $start $end popd > /dev/null echo "Signed" }