mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-21 22:28:37 -05:00
Improve Pageant's error reporting for private key load failures.
[originally from svn r5409]
This commit is contained in:
parent
bd6eadd196
commit
c60aa6b2f5
@ -402,6 +402,7 @@ static void add_keyfile(Filename filename)
|
|||||||
int ret;
|
int ret;
|
||||||
int attempts;
|
int attempts;
|
||||||
char *comment;
|
char *comment;
|
||||||
|
const char *error = NULL;
|
||||||
struct PassphraseProcStruct pps;
|
struct PassphraseProcStruct pps;
|
||||||
int type;
|
int type;
|
||||||
int original_pass;
|
int original_pass;
|
||||||
@ -424,18 +425,20 @@ static void add_keyfile(Filename filename)
|
|||||||
int i, nkeys, bloblen, keylistlen;
|
int i, nkeys, bloblen, keylistlen;
|
||||||
|
|
||||||
if (type == SSH_KEYTYPE_SSH1) {
|
if (type == SSH_KEYTYPE_SSH1) {
|
||||||
if (!rsakey_pubblob(&filename, &blob, &bloblen, NULL)) {
|
if (!rsakey_pubblob(&filename, &blob, &bloblen, &error)) {
|
||||||
MessageBox(NULL, "Couldn't load private key.", APPNAME,
|
char *msg = dupprintf("Couldn't load private key (%s)", error);
|
||||||
MB_OK | MB_ICONERROR);
|
MessageBox(NULL, msg, APPNAME, MB_OK | MB_ICONERROR);
|
||||||
|
sfree(msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
keylist = get_keylist1(&keylistlen);
|
keylist = get_keylist1(&keylistlen);
|
||||||
} else {
|
} else {
|
||||||
unsigned char *blob2;
|
unsigned char *blob2;
|
||||||
blob = ssh2_userkey_loadpub(&filename, NULL, &bloblen, NULL);
|
blob = ssh2_userkey_loadpub(&filename, NULL, &bloblen, &error);
|
||||||
if (!blob) {
|
if (!blob) {
|
||||||
MessageBox(NULL, "Couldn't load private key.", APPNAME,
|
char *msg = dupprintf("Couldn't load private key (%s)", error);
|
||||||
MB_OK | MB_ICONERROR);
|
MessageBox(NULL, msg, APPNAME, MB_OK | MB_ICONERROR);
|
||||||
|
sfree(msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* For our purposes we want the blob prefixed with its length */
|
/* For our purposes we want the blob prefixed with its length */
|
||||||
@ -515,6 +518,7 @@ static void add_keyfile(Filename filename)
|
|||||||
sfree(blob);
|
sfree(blob);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error = NULL;
|
||||||
if (type == SSH_KEYTYPE_SSH1)
|
if (type == SSH_KEYTYPE_SSH1)
|
||||||
needs_pass = rsakey_encrypted(&filename, &comment);
|
needs_pass = rsakey_encrypted(&filename, &comment);
|
||||||
else
|
else
|
||||||
@ -548,9 +552,9 @@ static void add_keyfile(Filename filename)
|
|||||||
} else
|
} else
|
||||||
*passphrase = '\0';
|
*passphrase = '\0';
|
||||||
if (type == SSH_KEYTYPE_SSH1)
|
if (type == SSH_KEYTYPE_SSH1)
|
||||||
ret = loadrsakey(&filename, rkey, passphrase, NULL);
|
ret = loadrsakey(&filename, rkey, passphrase, &error);
|
||||||
else {
|
else {
|
||||||
skey = ssh2_load_userkey(&filename, passphrase, NULL);
|
skey = ssh2_load_userkey(&filename, passphrase, &error);
|
||||||
if (skey == SSH2_WRONG_PASSPHRASE)
|
if (skey == SSH2_WRONG_PASSPHRASE)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
else if (!skey)
|
else if (!skey)
|
||||||
@ -570,8 +574,9 @@ static void add_keyfile(Filename filename)
|
|||||||
if (comment)
|
if (comment)
|
||||||
sfree(comment);
|
sfree(comment);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
MessageBox(NULL, "Couldn't load private key.", APPNAME,
|
char *msg = dupprintf("Couldn't load private key (%s)", error);
|
||||||
MB_OK | MB_ICONERROR);
|
MessageBox(NULL, msg, APPNAME, MB_OK | MB_ICONERROR);
|
||||||
|
sfree(msg);
|
||||||
if (type == SSH_KEYTYPE_SSH1)
|
if (type == SSH_KEYTYPE_SSH1)
|
||||||
sfree(rkey);
|
sfree(rkey);
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user