fail() returned NULL, windows need return 0;
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@2410 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
7939f0b010
commit
85ab01a8cd
|
@ -246,7 +246,6 @@ int pkcs11_find_key(PKCS11_CTX * ctx, PKCS11_KEY **key, char* passphrase, char*
|
||||||
{
|
{
|
||||||
/* need to confirm if passphrase required, perhaps substitute callback */
|
/* need to confirm if passphrase required, perhaps substitute callback */
|
||||||
|
|
||||||
#define fail(msg) { fprintf(stderr,msg); return NULL;}
|
|
||||||
PKCS11_SLOT *slot, *slot_list;
|
PKCS11_SLOT *slot, *slot_list;
|
||||||
PKCS11_TOKEN *tok;
|
PKCS11_TOKEN *tok;
|
||||||
PKCS11_CERT *certs;
|
PKCS11_CERT *certs;
|
||||||
|
@ -351,8 +350,10 @@ int pkcs11_find_key(PKCS11_CTX * ctx, PKCS11_KEY **key, char* passphrase, char*
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slot_nr == -1) {
|
if (slot_nr == -1) {
|
||||||
if (!(slot = PKCS11_find_token(ctx)))
|
if (!(slot = PKCS11_find_token(ctx))) {
|
||||||
fail("didn't find any tokens\n");
|
fprintf(stderr,"didn't find any tokens\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
} else if (slot_nr >= 0 && slot_nr < count)
|
} else if (slot_nr >= 0 && slot_nr < count)
|
||||||
slot = slot_list + slot_nr;
|
slot = slot_list + slot_nr;
|
||||||
else {
|
else {
|
||||||
|
@ -382,8 +383,10 @@ int pkcs11_find_key(PKCS11_CTX * ctx, PKCS11_KEY **key, char* passphrase, char*
|
||||||
|
|
||||||
|
|
||||||
if(verbose) {
|
if(verbose) {
|
||||||
if (PKCS11_enumerate_certs(tok, &certs, &count))
|
if (PKCS11_enumerate_certs(tok, &certs, &count)) {
|
||||||
fail("unable to enumerate certificates\n");
|
fprintf(stderr,"unable to enumerate certificates\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
fprintf(stderr,"Found %u certificate%s:\n", count, (count <= 1) ? "" : "s");
|
fprintf(stderr,"Found %u certificate%s:\n", count, (count <= 1) ? "" : "s");
|
||||||
for (n = 0; n < count; n++) {
|
for (n = 0; n < count; n++) {
|
||||||
PKCS11_CERT *c = certs + n;
|
PKCS11_CERT *c = certs + n;
|
||||||
|
@ -401,8 +404,10 @@ int pkcs11_find_key(PKCS11_CTX * ctx, PKCS11_KEY **key, char* passphrase, char*
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
if (PKCS11_enumerate_keys(tok, &keys, &count))
|
if (PKCS11_enumerate_keys(tok, &keys, &count)) {
|
||||||
fail("unable to enumerate keys\n");
|
fprintf(stderr,"unable to enumerate keys\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (count)
|
if (count)
|
||||||
break;
|
break;
|
||||||
if (logged_in || !tok->loginRequired)
|
if (logged_in || !tok->loginRequired)
|
||||||
|
@ -418,7 +423,8 @@ int pkcs11_find_key(PKCS11_CTX * ctx, PKCS11_KEY **key, char* passphrase, char*
|
||||||
pin = NULL;
|
pin = NULL;
|
||||||
}*/
|
}*/
|
||||||
passphrase=NULL;
|
passphrase=NULL;
|
||||||
fail("Card login failed\n");
|
fprintf(stderr,"Card login failed\n");
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
logged_in++;
|
logged_in++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue