Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

: net.sf.scuba.smartcards.CardServiceException: File not found, CAPDU exception #6

Open
jonneymendoza opened this issue Jan 13, 2021 · 8 comments

Comments

@jonneymendoza
Copy link

jonneymendoza commented Jan 13, 2021

Hi i grabbed your project an ran it on my Samsung S8 device and i get an exception when i try to do the NFC conact part on the app using my british passport.

the MRZ scanning seems to work but not the NFC

Full stacktrace below

2021-01-13 16:30:23.885 25172-28874/com.alimert.passportreader W/MainActivity: net.sf.scuba.smartcards.CardServiceException: File not found, CAPDU = 00A4020C02011D, RAPDU = 6A82 (SW = 0x6A82: FILE NOT FOUND)
        at org.jmrtd.protocol.ReadBinaryAPDUSender.checkStatusWordAfterFileOperation(ReadBinaryAPDUSender.java:218)
        at org.jmrtd.protocol.ReadBinaryAPDUSender.sendSelectFile(ReadBinaryAPDUSender.java:79)
        at org.jmrtd.DefaultFileSystem.sendSelectFile(DefaultFileSystem.java:321)
        at org.jmrtd.DefaultFileSystem.getFileInfo(DefaultFileSystem.java:272)
        at org.jmrtd.DefaultFileSystem.getSelectedPath(DefaultFileSystem.java:129)
        at net.sf.scuba.smartcards.CardFileInputStream.<init>(CardFileInputStream.java:60)
        at org.jmrtd.PassportService.getInputStream(PassportService.java:595)
        at com.alimert.passportreader.ui.MainActivity$ReadTask.doInBackground(MainActivity.java:250)
        at com.alimert.passportreader.ui.MainActivity$ReadTask.doInBackground(MainActivity.java:223)
        at android.os.AsyncTask$3.call(AsyncTask.java:378)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919)```
@alimertozdemir
Copy link
Owner

I think MRZ scanning is the problem. Sure it reads MRZ but extracted one of the passportNumber, birthDate and expirationDate values could be wrong. Could you please control these three values with writing log?

BACKeySpec bacKey = new BACKey(passportNumber, birthDate, expirationDate);

@Redd1ntong
Copy link

I have the same issue, the problem isnt the MRZ, i am sure.
I am trying to build in my own app and i have the same issue, but if i do the same in your app, all works ok. In my app, if i try, it's works but without image.
I am writing logs, all seems ok

@ashpakouski
Copy link

Hello, @alimertozdemir, @Redd1ntong, did you eventually find the reason of the issue? Am facing it too and I'm already out of ideas.

@YesidMarin
Copy link

Any solution?

@ElMostafaIdrassi
Copy link

@alimertozdemir This is not a MRZ issue. It looks like the app is trying to read EF 011D which corresponds to EF.CardSecurity, and it fails with 6A82 (File not found). Not all chips come with EF.CardSecurity, it is only mandatory if the chip supports PACE-CAM. The only EF that is mandatory for PACE is EF.CardAccess, which the app is not even using.
This results in the app selecting the applet without doing proper PACE beforehand.

The code in question is the following:

boolean paceSucceeded = false;
try {
CardSecurityFile cardSecurityFile = new CardSecurityFile(service.getInputStream(PassportService.EF_CARD_SECURITY));
Collection<SecurityInfo> securityInfoCollection = cardSecurityFile.getSecurityInfos();
for (SecurityInfo securityInfo : securityInfoCollection) {
if (securityInfo instanceof PACEInfo) {
PACEInfo paceInfo = (PACEInfo) securityInfo;
service.doPACE(bacKey, paceInfo.getObjectIdentifier(), PACEInfo.toParameterSpec(paceInfo.getParameterId()), null);
paceSucceeded = true;
}
}
} catch (Exception e) {
Log.w(TAG, e);
}

I think that adding the code to read EF.CardAccess will solve the issue.

@fuatebuzeynebKplus
Copy link

fuatebuzeynebKplus commented Jun 10, 2024

Did you find a solution to the problem?? I replaced this line with real data but still the same problem

BACKeySpec bacKey = new BACKey("U2426****", "010***", "260***");

@alimertozdemir @alimertozdemir @jonneymendoza @YesidMarin @Redd1ntong

please if you have any idea or solution share with me

@mohamed00736
Copy link

mohamed00736 commented Sep 10, 2024

Hello , Am having the same probleme , am scanning NFC of ID CARD and Passport very well , but withe Driver Licence its not working at all here is the error log : Error reading from card :

net.sf.scuba.smartcards.CardServiceException: Error occured, CAPDU = 00A4040C07A0000002471001, RAPDU =6A86 (SW = 0x6A86: INCORRECT P1P2)at org.jmrtd.protocol.ReadBinaryAPDUSender.checkStatusWordAfterFileOperation(ReadBinaryAPDUSender.java:226)

at org.jmrtd.protocol.ReadBinaryAPDUSender.sendSelectApplet(ReadBinaryAPDUSender.java:58)

at org.jmrtd.PassportService.sendSelectApplet(PassportService.java:332)

@mohamed00736
Copy link

mohamed00736 commented Sep 17, 2024

i made some progress , i created a class Called DriverLicnceService , its the same as PassportService but i only changed this : protected val APPLET_AID: ByteArray = byteArrayOf(0xA0.toByte(), 0x00, 0x00, 0x02, 0x48, 0x02, 0x00) , now i can read the card , but the data seems a bit corrupted , some values are aempty , some fields looks they have some weird characters

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants