X-Git-Url: https://code.wpia.club/?p=nre.git;a=blobdiff_plain;f=commonFunctions;h=8b12bf43a3de730cae46440ffeb22cb2fb8bde43;hp=aa1daffac64b4a0f7a3a4455007fcdbe1a14baa7;hb=6ba8d258f7f3601d8e0be4425f790210b4ea4a87;hpb=69a024b8652e0f0c5203954f322b79a3f0096446 diff --git a/commonFunctions b/commonFunctions index aa1daff..8b12bf4 100755 --- a/commonFunctions +++ b/commonFunctions @@ -22,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" }