Hello,
I've encountered an issue when using Thunderbird with MUSCLE PKCS#11 -
likely to be an issue with other applications too. The issue is that after
removing and reinserting a smart card, MUSCLE continuously returns an
invalid handle error without any way of getting a new correct handle.
Here are the details of the issue:
After removing and re-inserting the smartcard in the reader, PKCS can no
longer access the card due to an invalid handle:
22/11 13:18:19 +C_GetSlotInfo : start
22/11 13:18:19 Checking slot: 1
22/11 13:18:19 Active session list:
22/11 13:18:19 (../PKCS11/src/p11x_slot.c 241): error: 0x9C59 "Handle is
invalid"
22/11 13:18:19 SlotInfo.flags: 6
22/11 13:18:19 -C_GetSlotInfo : end RV(0x0)
Checking muscle source code, I found that MSCReleaseConnection releases the
scard connection but keeps the context (see below under the comment of
"Release Context"). Future calls to muscle return "Handle is invalid" as
pConnection->hContext is not reset. I (temporarily) solve the issue by
commenting this part of code. However, I don't know if this will cause
unwanted side affects.
MSC_RV MSCReleaseConnection(MSCLPTokenConnection pConnection,
MSCULong32 endAction)
{
MSCLong32 rv = SCARD_S_SUCCESS;
MSCLong32(*libPL_MSCFinalizePlugin) (MSCLPTokenConnection);
MSCPVoid32 vFunction;
vFunction = NULL;
if (pConnection == NULL)
return MSC_INVALID_PARAMETER;
if (pConnection->tokenLibHandle == 0 ||
pConnection->hContext == 0 || pConnection->hCard == 0)
{
return MSC_INVALID_HANDLE;
}
/*
* Select finalization routine for the token plugin
*/
vFunction = pConnection->libPointers.pvfFinalizePlugin;
if (vFunction == NULL)
{
Log2(PCSC_LOG_ERROR, "Error: Card service failure: %s",
"FinalizePlugin function missing");
return MSC_INTERNAL_ERROR;
}
libPL_MSCFinalizePlugin = (MSCLong32(*)
(MSCLPTokenConnection)) vFunction;
/*
* Stop and clean up the plugin
*/
rv = (*libPL_MSCFinalizePlugin) (pConnection);
/*
* Disconnect from the token
*/
if (pConnection->hCard != 0)
{
rv = SCardDisconnect(pConnection->hCard, endAction);
if (pcscToMSC(rv) != MSC_SUCCESS)
return pcscToMSC(rv);
}
/*
* Unload the token driver
*/
if (pConnection->tokenLibHandle != 0)
{
rv = TPUnloadToken(pConnection);
pConnection->tokenLibHandle = 0;
}
/*
* Release Context
*/
if (pConnection->hContext != 0)
{
rv = SCardReleaseContext(pConnection->hContext);
if (pcscToMSC(rv) != MSC_SUCCESS)
return pcscToMSC(rv);
}
pConnection->tokenLibHandle = 0;
pConnection->hCard = 0;
pConnection->hContext = 0;
pConnection->shareMode = 0;
return MSC_SUCCESS;
}
Regards,
IA
_______________________________________________
Muscle mailing list
[email protected]
http://lists.drizzle.com/mailman/listinfo/muscle