proxmox-acme: add _isRSA and _isEcc helpers

the _isRSA one is used by the new yc plugin, but doesn't hurt much to
already include the very similar Ecc one too.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-12-07 13:26:56 +01:00
parent da4c6a7fc1
commit 9fe5356aed

View File

@ -649,6 +649,24 @@ _stat() {
stat -c '%U:%G' "$1" 2>/dev/null
}
#keyfile
_isRSA() {
keyfile=$1
if grep "BEGIN RSA PRIVATE KEY" "$keyfile" >/dev/null 2>&1 || ${ACME_OPENSSL_BIN:-openssl} rsa -in "$keyfile" -noout -text | grep "^publicExponent:" >/dev/null 2>&1; then
return 0
fi
return 1
}
#keyfile
_isEcc() {
keyfile=$1
if grep "BEGIN EC PRIVATE KEY" "$keyfile" >/dev/null 2>&1 || ${ACME_OPENSSL_BIN:-openssl} ec -in "$keyfile" -noout -text 2>/dev/null | grep "^NIST CURVE:" >/dev/null 2>&1; then
return 0
fi
return 1
}
_time() {
date -u "+%s"
}