]> WPIA git - nre.git/blobdiff - commonFunctions.bash
upd: adjust duration of server certificates
[nre.git] / commonFunctions.bash
index 1c1ffb18e7d0a02dd23a77c8e7158b7703e59d95..a433fbea71e3158793cdf9bf22f0704c9b1d260d 100644 (file)
@@ -3,7 +3,7 @@
 
 genKey(){ #subj, internalName
     openssl genrsa -out $2.key ${KEYSIZE}
-    openssl req -new -key $2.key -out $2.csr -subj "$1/O=Test Environment CA Ltd./OU=Test Environment CAs/C=AU"
+    openssl req -new -key $2.key -out $2.csr -subj "$1/O=$ORGANIZATION/OU=$ORGANIZATIONAL_UNIT/C=$COUNTRY"
 
 }
 
@@ -30,12 +30,22 @@ caSign(){ # csr,ca,config,start,end
     echo "$start $end"
     pushd $2.ca > /dev/null
     if [[ "$2" == "root" && "$1" == root.* ]]; then
-       signkey="-selfsign"
+        signkey="-selfsign"
     else
-       signkey="-cert key.crt"
+        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"
 }
 
+findLibfaketime() {
+    for candidate in /usr/lib/faketime/libfaketime.so.1 /usr/lib/*/faketime/libfaketime.so.1; do
+        if [[ -f "$candidate" ]]; then
+            printf '%s\n' "$candidate"
+            return
+        fi
+    done
+    printf >&2 'error: no libfaketime found\n'
+    exit 1 # unfortunately, this will only exit the $() subshell
+}