]> git.proxmox.com Git - proxmox-acme.git/commitdiff
proxmox-acme: add _isRSA and _isEcc helpers
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 7 Dec 2022 12:26:56 +0000 (13:26 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 7 Dec 2022 12:27:48 +0000 (13:27 +0100)
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>
src/proxmox-acme

index 637a405b85dbc1fbf3728ed44dbcfbe2c09f6d01..8d022c69bf6b0f74e8d580887d1123d5826d5b45 100644 (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"
 }