View | Details | Raw Unified | Return to bug 3429 | Differences between
and this patch

Collapse All | Expand All

(-)a/ssh-keygen.c (-2 / +10 lines)
Lines 2439-2445 load_sign_key(const char *keypath, const struct sshkey *pubkey) Link Here
2439
	char *privpath = xstrdup(keypath);
2439
	char *privpath = xstrdup(keypath);
2440
	static const char * const suffixes[] = { "-cert.pub", ".pub", NULL };
2440
	static const char * const suffixes[] = { "-cert.pub", ".pub", NULL };
2441
	struct sshkey *ret = NULL, *privkey = NULL;
2441
	struct sshkey *ret = NULL, *privkey = NULL;
2442
	int r;
2442
	int r, waspub = 0;
2443
	struct stat st;
2443
2444
2444
	/*
2445
	/*
2445
	 * If passed a public key filename, then try to locate the corresponding
2446
	 * If passed a public key filename, then try to locate the corresponding
Lines 2454-2461 load_sign_key(const char *keypath, const struct sshkey *pubkey) Link Here
2454
		privpath[plen - slen] = '\0';
2455
		privpath[plen - slen] = '\0';
2455
		debug_f("%s looks like a public key, using private key "
2456
		debug_f("%s looks like a public key, using private key "
2456
		    "path %s instead", keypath, privpath);
2457
		    "path %s instead", keypath, privpath);
2458
		waspub = 1;
2457
	}
2459
	}
2458
	if ((privkey = load_identity(privpath, NULL)) == NULL) {
2460
	if (waspub && stat(privpath, &st) != 0 && errno == ENOENT)
2461
		fatal("No private key found for public key \"%s\"", keypath);
2462
	if ((r = sshkey_load_private(privpath, "", &privkey, NULL)) != 0 &&
2463
	    (r != SSH_ERR_KEY_WRONG_PASSPHRASE)) {
2464
		debug_fr(r, "load private key \"%s\"", privpath);
2465
		fatal("No private key found for \"%s\"", privpath);
2466
	} else if ((privkey = load_identity(privpath, NULL)) == NULL) {
2459
		error("Couldn't load identity %s", keypath);
2467
		error("Couldn't load identity %s", keypath);
2460
		goto done;
2468
		goto done;
2461
	}
2469
	}

Return to bug 3429