Skip to content

Commit

Permalink
pkcs11-tool: ignore CRYPTOKI_ALREADY_INITIALIZED error
Browse files Browse the repository at this point in the history
OpenSC#118
Print warning and ignore 'Cryptoki library has already been initialized'  error
returned by C_Initialize().
  • Loading branch information
viktorTarasov committed Mar 10, 2013
1 parent 8e95abf commit a24ecd0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/tools/pkcs11-tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,9 @@ int main(int argc, char * argv[])
util_fatal("Failed to load pkcs11 module");

rv = p11->C_Initialize(NULL);
if (rv != CKR_OK)
if (rv == CKR_CRYPTOKI_ALREADY_INITIALIZED)
printf("\n*** Cryptoki library has already been initialized ***\n");
else if (rv != CKR_OK)
p11_fatal("C_Initialize", rv);

if (do_show_info)
Expand Down Expand Up @@ -4273,7 +4275,9 @@ static void test_kpgen_certwrite(CK_SLOT_ID slot, CK_SESSION_HANDLE session)
util_fatal("Failed to load pkcs11 module");

rv = p11->C_Initialize(NULL);
if (rv != CKR_OK)
if (rv == CKR_CRYPTOKI_ALREADY_INITIALIZED)
printf("\n*** Cryptoki library has already been initialized ***\n");
else if (rv != CKR_OK)
p11_fatal("C_Initialize", rv);

rv = p11->C_OpenSession(opt_slot, CKF_SERIAL_SESSION| CKF_RW_SESSION,
Expand Down

0 comments on commit a24ecd0

Please sign in to comment.