tags:

views:

28

answers:

1

Hello there,

I load dynamically pkcs11 security Provider in java and it works as long as the smart card reader is inserted before running the application. Could anyone please tell me how to detect a smartcard hotplug when the application is running? Actually I need something like pcsc_scan in java. The environment is Ubuntu 9.10 with java 1.6.0_20. Thanks in advance

A: 

PKCS#11 doesn't define a standard way to actively notify the application about device insertion/removal. The best you can do is to run a thread which will check the number of slots and their state once a second or so.

Eugene Mayevski 'EldoS Corp
Yes, I did so... I looks like that p11 = PKCS11.getInstance("/usr/local/lib/libsiecap11.so", "C_GetFunctionList", null, false); long[] slots = p11.C_GetSlotList(true);And I encountered the very same problem. The good thing is that I could see whenever a card is removed, but still number of slots does not change while the application is running. For example - if I put a smartcard reader in a usb slot and run my application the number of slots will be 1. Although I put another smartcard reader (while application is still running) the number of slots will remain 1.
The number of slots is usually the same, but their state will change. The fact that putting two readers (are they of the same vendor?) doesn't change the number of slots can be a defect of PKCS#11 driver. In this case you need to check with driver vendor.
Eugene Mayevski 'EldoS Corp
Yes the two cards are from the same vendor (manufacturerID: Siemens AG (C)... model: CardOS V4.3B (C))... So if I start the application with no smartcard plugged in advance - the method C_GetSlotList() will always return 0. For example the PC/SC device scanner (pcsc_scan) is working fine and detects whenever I plug or unplug a smarcard in the computer.
then it's a problem of PKCS#11 driver itself. We saw such problems before with some hardwares. PKCS#11 drivers are far from ideal (partially due to ambiguities in the standard, partially due to programming errors).
Eugene Mayevski 'EldoS Corp