1

I have smartcard usb readers ( ACR38 and ACR38 CCID ). I have some C# code that works to connect, send apdu commands perfectly with winscard.dll ((SCardEstablishContext, SCardConnect, SCardControl methods).

I need to do this with java, and I use javax.smartcardio api, with some code similar to this: PCSC sample in java

The reader and inserted card are detected ok, but there is a delay (15-20 seconds) when I try to connect. This delay only appears when card is inserted first time. If I extract-insert same card there is no delay. If I extract card and insert another one, delayed again. I can't connect the first 15-20 seconds, with java program running or not.

When reader/card is connected, I can send apdu commands perfectly.

Otherwise with C# and winscard.dll api, there is not delay.

I test with win7, win8, ACR38 reader, ACR38 CCID reader...

Why I have this delay?

HalSeldon
  • 43
  • 1
  • 7
  • It would be helpful if you showed a minimal version of the working C# code and a minimal version if the Java coe that results in the delay. – Michael Roland Mar 12 '14 at 18:52
  • possible duplicate of [javax.smartcardio SCARD\_SHARE\_SHARED and SLEE4442 delay](http://stackoverflow.com/questions/22334110/javax-smartcardio-scard-share-shared-and-slee4442-delay) – Michael Roland Mar 12 '14 at 18:56

1 Answers1

0

If this happens only when the card is inserted for the first time as you have described it is possible that some other process may have exclusive connection open to the reader. It may be windows built-in certificate propagation service or some similar application that is part of the card middleware you may have installed. It may also be a Windows update trying to download a minidriver for your card.

jariq
  • 11,681
  • 3
  • 33
  • 52
  • ok, but why C# code (winscard.dll based) works ok without delay? – HalSeldon Mar 12 '14 at 14:08
  • Java also uses winscard.dll in its internal implementation. Maybe the delay is related to the communication protocol detection that is performed when you call: `Card card = terminal.connect("*");` Could you try using "T=0", "T=1" or "T=CL" instead of "*" if it will perform faster? – jariq Mar 12 '14 at 14:24
  • I used same protocol, undefined, "0" for winscard.dll, "*" for Java.... it's possible to pass sharemode to javax.smarcardio to test with Direct mode? – HalSeldon Mar 12 '14 at 14:29
  • I am not sure. I wanted to check in javax.smartcardio.* source code but I am having trouble finding it anywhere on the internet (maybe it is Oracle's proprietary part?). However it may be helpful if you could somehow get the log of the PCSC (winscard.dll) calls made from JRE. By doing a simple google search I have found [The APDU spying tool](http://www.idrix.fr/Root/content/category/7/25/48/) but I have never used it before. – jariq Mar 12 '14 at 16:18
  • You may also look at [my older answer about javax.smartcardio](http://stackoverflow.com/questions/22191549/java-smart-card-reading-scosta-smart-card/22197782#22197782) and try [jnasmartcardio](https://github.com/jnasmartcardio/jnasmartcardio) project. – jariq Mar 12 '14 at 16:29
  • @user3407487 If you use `SCARD_PROTOCOL_UNDEFINED` (i.e. 0) in C#, could it be that you open the connection in `SCARD_SHARE_DIRECT` mode? – Michael Roland Mar 12 '14 at 18:54
  • 1
    Ok...I test all possible modes, and java code. Jariq was right... There is something OS relative. I tested this with win 8.1 and there is a delay...otherwise with win 7 works well. There is not any driver assistant launched when I put card, but card was not responsive the first 20 seconds. Any idea? – HalSeldon Mar 14 '14 at 12:08