From 9fe5356aede7ebca0372ba06a7544c809afb6505 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 7 Dec 2022 13:26:56 +0100 Subject: [PATCH] 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 --- src/proxmox-acme | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/proxmox-acme b/src/proxmox-acme index 637a405..8d022c6 100644 --- a/src/proxmox-acme +++ b/src/proxmox-acme @@ -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" }