- Do not try to C_Login if the token doesn't require a login
git-svn-id: https://www.opensc-project.org/svnp/opensc/trunk@1127 c6295689-39f2-0310-b995-f0e70906c6a9
This commit is contained in:
parent
0f29e7543e
commit
2e673aead6
|
@ -346,15 +346,18 @@ main(int argc, char * const argv[])
|
|||
|
||||
/* Identify which pin to enter */
|
||||
|
||||
if (info.flags & CKF_PROTECTED_AUTHENTICATION_PATH)
|
||||
if (info.flags & CKF_PROTECTED_AUTHENTICATION_PATH) {
|
||||
pin = NULL;
|
||||
else {
|
||||
} else
|
||||
if (info.flags & CKF_LOGIN_REQUIRED) {
|
||||
if (opt_pin == NULL)
|
||||
pin = getpass("Please enter PIN: ");
|
||||
else
|
||||
pin = opt_pin;
|
||||
if (!pin || !*pin)
|
||||
return 1;
|
||||
} else {
|
||||
goto skip_login;
|
||||
}
|
||||
rv = p11->C_Login(session, CKU_USER, (CK_UTF8CHAR *) pin,
|
||||
pin == NULL ? 0 : strlen(pin));
|
||||
|
@ -362,6 +365,7 @@ main(int argc, char * const argv[])
|
|||
p11_fatal("C_Login", rv);
|
||||
}
|
||||
|
||||
skip_login:
|
||||
if (do_sign) {
|
||||
if (!find_object(session, CKO_PRIVATE_KEY, &object, NULL, 0, 0))
|
||||
fatal("Private key not found");
|
||||
|
|
Loading…
Reference in New Issue