-
Notifications
You must be signed in to change notification settings - Fork 11
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
Грешка приликом читања личне карте за странце #30
Comments
Preći ću na engleski, pošto mislim da ćemo se tako lakše razumeti: First, thank you for bringing this up, and thank you for very detailed description of the problem. I suppose you have ID card for foreigners, and it has a slightly different structure of data on card. As BasCelik is developed completely independently from official apps, there are some edge cases like this that I didn't cover. Unfortunately, I don't have access to ID cards for foreigners on which I could test, so I can't resolve bug, even if I am pretty sure what is happening. You can try to fix bug yourself (I can introduce you to the code and the workflow), or maybe we could meet for a coffee so I could see what is exactly happening (if you are in Belgrade). |
Thank you for the answer. |
I will answer here your question from #29 about reading from smart cards (because that issue isn't a bug, a this really is). There is no way (AFAIK) you can read all data from smart card. Smart card behaves like small filesystem, and data is divided into 'files'. Each file has an address, and you must send a request with the exact address to be able to read that file. On Serbian ID cards, data is stored in 4 files. Because the Serbian vehicle card has the same ATR as the Serbian ID card, Bas Celik tries to distinct these two documents by reading Please, in tempIdCard := Gemalto{smartCard: sc}
if tempIdCard.testGemalto() {
card = Gemalto{smartCard: sc}
} else {
card = VehicleCard{smartCard: sc}
} to card = Gemalto{smartCard: sc} This will force the program to process your card as an ID card. Your card will be processed inside func readIdCard[Id IdDocument](card Id) (*document.IdDocument, error) {
doc := document.IdDocument{}
rsp, err := card.readFile(DOCUMENT_FILE_LOC, false)
if err != nil {
fmt.Println("reading document file:", err)
} else {
fields, err := parseTLV(rsp)
if err != nil {
fmt.Println(err)
} else {
assignField(fields, 1546, &doc.DocumentNumber)
assignField(fields, 1547, &doc.DocumentType)
assignField(fields, 1548, &doc.DocumentSerialNumber)
assignField(fields, 1549, &doc.IssuingDate)
assignField(fields, 1550, &doc.ExpiryDate)
assignField(fields, 1551, &doc.IssuingAuthority)
localization.FormatDate(&doc.IssuingDate)
localization.FormatDate(&doc.ExpiryDate)
}
}
rsp, err = card.readFile(PERSONAL_FILE_LOC, false)
if err != nil {
fmt.Println("reading personal file:", err)
} else {
fields, err := parseTLV(rsp)
if err != nil {
fmt.Println(err)
} else {
assignField(fields, 1558, &doc.PersonalNumber)
assignField(fields, 1559, &doc.Surname)
assignField(fields, 1560, &doc.GivenName)
assignField(fields, 1561, &doc.ParentGivenName)
assignField(fields, 1562, &doc.Sex)
assignField(fields, 1563, &doc.PlaceOfBirth)
assignField(fields, 1564, &doc.CommunityOfBirth)
assignField(fields, 1565, &doc.StateOfBirth)
assignField(fields, 1566, &doc.DateOfBirth)
localization.FormatDate(&doc.DateOfBirth)
}
}
rsp, err = card.readFile(RESIDENCE_FILE_LOC, false)
if err != nil {
fmt.Println("reading residence file:", err)
} else {
fields, err := parseTLV(rsp)
if err != nil {
fmt.Println(err)
} else {
assignField(fields, 1568, &doc.State)
assignField(fields, 1569, &doc.Community)
assignField(fields, 1570, &doc.Place)
assignField(fields, 1571, &doc.Street)
assignField(fields, 1572, &doc.AddressNumber)
assignField(fields, 1573, &doc.AddressLetter)
assignField(fields, 1574, &doc.AddressEntrance)
assignField(fields, 1575, &doc.AddressFloor)
assignField(fields, 1578, &doc.AddressApartmentNumber)
assignField(fields, 1580, &doc.AddressDate)
localization.FormatDate(&doc.AddressDate)
}
}
rsp, err = card.readFile(PHOTO_FILE_LOC, true)
if err != nil {
fmt.Println("reading photo file:", err)
} else {
doc.Portrait, _, err = image.Decode(bytes.NewReader(rsp))
if err != nil {
fmt.Println("decoding photo file:", err)
}
}
return &doc, nil
} If you don't conclude anything from this, then we need to peek into the official app to see how it communicates with foreigners cards. Btw, I suppose that you know how to compile go programs. Compiling Bas Celik should not be a problem on Linux. If you want to skip building the whole GUI version you can do: go build -tags "cli" . |
Thank you for the help! I think we have two possible ways: either I take my card and go to Belgrade; or I can install linux on a machine with the cardreader plugged in and give you an ssh access to it (if you like the idea, of course). |
Hm, interesting. It seem that ID cards for foreigners have different initialization sequence. This complicates things Very cool idea with ssh :) We can try that, but I am afraid I will have to test your card with the official app. Then I will be able to see exactly what data is transferred to the card. BTW, if you are in NS, or somewhere near BG, I can drop by there. Feel free to send me a mail when you have time |
HI! I am in Belgrade and I have the TRP card )) If you want we can meet and debug the issue )) |
The response for the initialization request seems to be OK ( |
@loskutov Thanks for information @X3KT0 @RodiAda @loskutov I just released v2 branch which among other things brings support for foreigner cards. Could you compile this branch and test your cards with it? Edit: If you have PDFs of your cards made by state app, please compare it with PDF created with Baš Čelik. It should have same values listed. |
Works like a charm for me! The only difference I see is the address format: with the state app, it's entitled as "Prebivalište i adresa stana" and the value is like "BEOGRAD, AREA, NEKA ULICA 001", whilst with Baš Čelik it's just "Prebivalište" and the value format is "NEKA ULICA 001, AREA, BEOGRAD". |
Great, glad it works now :) The difference in the address field label was already noted in #6. But, once again, I tested this today with two IDs and the official app produces PDFs with "Prebivalište". It seems that the label depends on some other field or maybe card release date. I am not sure. The Field I will change the order in the address field, that is a confirmed bug :) I usually strive to produce pixel perfect PDFs. |
Графички Баш Челик одма улази у циклус "читање-грешка".
CLI верзия каже "Error saving document: reading card: reading card: reading document 0 file: parsing file header: invalid length" па се завршава.
Исти баш челик са истим хардвер читачом ради са картицом здравственог осигурања на истом рачунару (онда проблем није у хардверу).
Исти хардвер читач добро ради са проблематичном картом на другом рачунару со Виндовзом (онда проблем није у карти).
ЛК има на себи сертификате.
ATR је 3bff9400008131804380318065b0850201f3120fff82900079
Издата је у априлу 2023.
Немам држављанске карте, онда не могу да проверим са њом.
The text was updated successfully, but these errors were encountered: