pki: Choose default digest based on the signature key
[strongswan.git] / src / pki / commands / acert.c
index 3a35b06..7099977 100644 (file)
@@ -32,7 +32,7 @@
 static int acert()
 {
        cred_encoding_type_t form = CERT_ASN1_DER;
-       hash_algorithm_t digest = HASH_SHA256;
+       hash_algorithm_t digest = HASH_UNKNOWN;
        certificate_t *ac = NULL, *cert = NULL, *issuer =NULL;
        private_key_t *private = NULL;
        public_key_t *public = NULL;
@@ -162,6 +162,10 @@ static int acert()
                error = "loading issuer private key failed";
                goto end;
        }
+       if (digest == HASH_UNKNOWN)
+       {
+               digest = get_default_digest(private);
+       }
        if (!private->belongs_to(private, public))
        {
                error = "issuer private key does not match issuer certificate";
@@ -287,7 +291,7 @@ static void __attribute__ ((constructor))reg()
                        {"not-before",          'F', 1, "date/time the validity of the AC starts"},
                        {"not-after",           'T', 1, "date/time the validity of the AC ends"},
                        {"dateform",            'D', 1, "strptime(3) input format, default: %d.%m.%y %T"},
-                       {"digest",                      'g', 1, "digest for signature creation, default: sha256"},
+                       {"digest",                      'g', 1, "digest for signature creation, default: key-specific"},
                        {"outform",                     'f', 1, "encoding of generated cert, default: der"},
                }
        });