Page 1 of 1

javax.smartcardio error: Could not obtain response

Posted: Mon Oct 02, 2017 3:16 am
by Diorin
I came across an problem when using the Java Smart Card I/O API. No matter when I send a command APDU to my applet, and this command returns any data, and an exception is thrown:

Exception in thread "main" javax.smartcardio.CardException: Could not obtain response
at sun.security.smartcardio.ChannelImpl.doTransmit(ChannelImpl.java:169)
at sun.security.smartcardio.ChannelImpl.transmit(ChannelImpl.java:73)



Does anybody know how do I solve this problem?

Re: javax.smartcardio error: Could not obtain response

Posted: Mon Oct 02, 2017 6:29 am
by marjkbadboy
I think that you are sending an APDU command case 1 (P3=0), just like:

Code: Select all

CLA INS P1 P2 Le


If your applet invoke the method

Code: Select all

setIncomingAndReceive()

, it will expect data from the APDU buffer, and if you don't send data, this exception will be throwed by smartcardio API.

Re: javax.smartcardio error: Could not obtain response

Posted: Mon Oct 02, 2017 11:48 am
by BrooksIQ
So as what has been mentioned above, even for APDU commands that are sent without any data attached. You have to send a dummy data attached to it.

At the applet side, do a setIncomingAndReceive()
first and ignore the retrieved dummy data. then proceed with your response.