]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: when signing a certificate with an RSA key, default to
authordjm@openbsd.org <djm@openbsd.org>
Fri, 24 Jan 2020 00:27:04 +0000 (00:27 +0000)
committerDamien Miller <djm@mindrot.org>
Sat, 25 Jan 2020 00:27:29 +0000 (11:27 +1100)
a safe signature algorithm (rsa-sha-512) if not is explicitly specified by
the user; ok markus@

OpenBSD-Commit-ID: e05f638f0be6c0266e1d3d799716b461011e83a9

ssh-keygen.c

index 564c3c4811a3c9dd27fe00e1b878ebd85086c407..f2192edb961eb426b9b18e4067b7e22273346b83 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-keygen.c,v 1.389 2020/01/24 00:00:31 djm Exp $ */
+/* $OpenBSD: ssh-keygen.c,v 1.390 2020/01/24 00:27:04 djm Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1788,10 +1788,14 @@ do_ca_sign(struct passwd *pw, const char *ca_key_path, int prefer_agent,
        }
        free(tmp);
 
-       if (key_type_name != NULL &&
-           sshkey_type_from_name(key_type_name) != ca->type)  {
-               fatal("CA key type %s doesn't match specified %s",
-                   sshkey_ssh_name(ca), key_type_name);
+       if (key_type_name != NULL) {
+               if (sshkey_type_from_name(key_type_name) != ca->type) {
+                       fatal("CA key type %s doesn't match specified %s",
+                           sshkey_ssh_name(ca), key_type_name);
+               }
+       } else if (ca->type == KEY_RSA) {
+               /* Default to a good signature algorithm */
+               key_type_name = "rsa-sha2-512";
        }
        ca_fp = sshkey_fingerprint(ca, fingerprint_hash, SSH_FP_DEFAULT);