X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=commonFunctions;h=168c610e03d8fa782e1ca45b02559647e3f3bc31;hb=26af5d502565f10a3d3d91192e5545f59075ca59;hp=5e1ffbf2929b40210e5ed3fb6ed98b2c56e17d97;hpb=2d5c169f43c88c0abedf60990b1fd622e8261b49;p=nre.git diff --git a/commonFunctions b/commonFunctions old mode 100755 new mode 100644 index 5e1ffbf..168c610 --- 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 "Signing: $BASE/$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" }