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

Erro na leitura do cartão #183

Open
GusGusGusGus opened this issue Sep 30, 2024 · 3 comments
Open

Erro na leitura do cartão #183

GusGusGusGus opened this issue Sep 30, 2024 · 3 comments

Comments

@GusGusGusGus
Copy link

GusGusGusGus commented Sep 30, 2024

OS: Windows 10 com WSL Ubuntu 24.04.1

fiz o setup para Linux e consigo correr o binário em WSL, tendo também feito a instalação através do flatpak.
No Powershell (admin), ao fazer usbipd list, consigo ver o leitor de cartões partilhado:

usbipd list
Connected:
BUSID  VID:PID    DEVICE                                                        STATE
... outros devices ...
5-1    0bda:0169  Microsoft Usbccid Smartcard Reader (WUDF), USB Mass Stora...  Shared
5-2    320f:5048  USB Input Device                                              Not shared
5-4    046d:c539  USB Input Device                                              Not shared

Corri o binário com /usr/local/bin/eidguiV2:

/usr/local/bin/eidguiV2
C++: Using application scaling.
C++: Application scaling:  1
C++: AppController started. App version:  "3.12.0 - 5410 [ 031c19f8b ]"
C++: currentCpuArchitecture(): "x86_64"
C++: prettyProductName(): "Ubuntu 24.04.1 LTS"
C++: Starting App with hardware graphics acceleration

De seguida tento ler e dá "Leitor de cartões não detectado" no GUI
Ao verificar lsusb , vi que não está presente o leitor de cartões no Ubuntu:

lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

Ao fazer usbipd attach --wsl --busid 5-1, já aparece no WSL:

lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0bda:0169 Realtek Semiconductor Corp. Mass Storage Device
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

Então, corri o binário com /usr/local/bin/eidguiV2 de novo.
"Leitor de cartões não detectado" no GUI

Nota: o leitor de cartões apresenta a luz vermelha de actividade e também a luz azul de detecção do cartão de cidadão


Experimentei correr o pacote através do flatpak, tendo feito a instalação conforme o manual do SDK:

flatpak run pt.gov.autenticacao
C++: Using application scaling.
C++: Application scaling:  1
C++: AppController started. App version:  "3.12.0 - 5410 [ 031c19f8b ]"
C++: currentCpuArchitecture(): "x86_64"
C++: prettyProductName(): "KDE Flatpak runtime"
C++: Starting App with hardware graphics acceleration

Erro: "Leitor de cartões não detectado" no GUI

Versão do pacote pcscd:

pcscd --version
pcsc-lite version 2.0.3.

Versão do Flatpak:

flatpak --version
Flatpak 1.14.6

[UPDATE]
O daemon PCSC parece reconhecer mas não autorizar o reader

 service pcscd status
○ pcscd.service - PC/SC Smart Card Daemon
     Loaded: loaded (/usr/lib/systemd/system/pcscd.service; indirect; preset: enabled)
     Active: inactive (dead) since Mon 2024-09-30 11:25:23 WEST; 29min ago
   Duration: 1min 38.143s
TriggeredBy: ● pcscd.socket
       Docs: man:pcscd(8)
    Process: 4209 ExecStart=/usr/sbin/pcscd --foreground --auto-exit $PCSCD_ARGS (code=exited, status=0/SUCCESS)
   Main PID: 4209 (code=exited, status=0/SUCCESS)

Sep 30 11:24:13 LAPTOP-EBPFBEC0 pcscd[4209]: 00000217 winscard_svc.c:355:ContextThread() Rejected unauthorized PC/SC client
Sep 30 11:24:13 LAPTOP-EBPFBEC0 pcscd[4209]: 00005894 auth.c:143:IsClientAuthorized() Process 4270 (user: 1002) is NOT authorized for action: access_pcsc
Sep 30 11:24:13 LAPTOP-EBPFBEC0 pcscd[4209]: 00000129 winscard_svc.c:355:ContextThread() Rejected unauthorized PC/SC client
Sep 30 11:24:13 LAPTOP-EBPFBEC0 pcscd[4209]: 00030839 auth.c:143:IsClientAuthorized() Process 4270 (user: 1002) is NOT authorized for action: access_pcsc
Sep 30 11:24:13 LAPTOP-EBPFBEC0 pcscd[4209]: 00000168 winscard_svc.c:355:ContextThread() Rejected unauthorized PC/SC client
Sep 30 11:24:18 LAPTOP-EBPFBEC0 pcscd[4209]: 05267145 auth.c:143:IsClientAuthorized() Process 4270 (user: 1002) is NOT authorized for action: access_pcsc
Sep 30 11:24:18 LAPTOP-EBPFBEC0 pcscd[4209]: 00000241 winscard_svc.c:355:ContextThread() Rejected unauthorized PC/SC client
Sep 30 11:24:18 LAPTOP-EBPFBEC0 pcscd[4209]: 00010665 auth.c:143:IsClientAuthorized() Process 4270 (user: 1002) is NOT authorized for action: access_pcsc
Sep 30 11:24:18 LAPTOP-EBPFBEC0 pcscd[4209]: 00000130 winscard_svc.c:355:ContextThread() Rejected unauthorized PC/SC client
Sep 30 11:25:23 LAPTOP-EBPFBEC0 systemd[1]: pcscd.service: Deactivated successfully.

Experimentei po-lo a correr em pano de fundo com

sudo pcscd -f
00000000 [139669154735424] utils.c:82:GetDaemonPid() Can't open /run/pcscd/pcscd.pid: No such file or directory

99999999 [139669137934016] auth.c:143:IsClientAuthorized() Process 4949 (user: 1002) is NOT authorized for action: access_pcsc
00000204 [139669137934016] winscard_svc.c:355:ContextThread() Rejected unauthorized PC/SC client
...
@GusGusGusGus
Copy link
Author

[UPDATES]

Consegui validar que o reader e cartão são detectados:

sudo pcsc_scan
PC/SC device scanner
V 1.7.1 (c) 2001-2022, Ludovic Rousseau <[email protected]>
Using reader plug'n play mechanism
Scanning present readers...
0: Generic USB2.0-CRW [Smart Card Reader Interface] (2007[redigido]) 00 00

Mon Sep 30 16:23:37 2024
Reader 0: Generic USB2.0-CRW [Smart Card Reader Interface] (2007[redigido]) 00 00
 Event number: 0
 Card state: **Card inserted**, 
 ATR: 3B FF _[redigido]_ D0

ATR: 3B FF `[redigido]` D0
+ TS = 3B --> Direct Convention
+ T0 = FF, Y(1): 1111, K: 15 (historical bytes)
 TA(1) = 96 --> Fi=512, Di=32, 16 cycles/ETU
   250000 bits/s at 4 MHz, fMax for Fi = 5 MHz => 312500 bits/s
 TB(1) = 00 --> VPP is not electrically connected
 TC(1) = 00 --> Extra guard time: 0
 TD(1) = 81 --> Y(i+1) = 1000, Protocol T = 1
-----
 TD(2) = 31 --> Y(i+1) = 0011, Protocol T = 1
-----
 TA(3) = FE --> IFSC: 254
 TB(3) = 43 --> Block Waiting Integer: 4 - Character Waiting Integer: 3
+ Historical bytes: 80 .. 00
 Category indicator byte: 80 (compact TLV data object)
   Tag: 3, len: 1 (card service data byte)
     Card service data byte: 80
       - Application selection: by full DF name
       - EF.DIR and EF.ATR access services: by GET RECORD(s) command
       - Card with MF
   Tag: 6, len: 5 (pre-issuing data)
     Data: B0 85 04 01 20
   Tag: 1, len: 2 (country code, ISO 3166-1)
     Country code: 0F FF
   Tag: 8, len: 2 (status indicator)
     SW: 9000
+ TCK = D0 (correct checksum)

Possibly identified card (using /usr/share/pcsc/smartcard_list.txt):
3B FF _[redigido]_ D0

inclusivamente, se eu remover o cartão e voltar a inserir, o pcsc_scan detecta os eventos:

Mon Sep 30 16:47:21 2024
 Reader 0: Generic USB2.0-CRW [Smart Card Reader Interface] (2007[redigido]) 00 00
  Event number: 1
  Card state: **Card removed**, 
   
Mon Sep 30 16:47:27 2024
 Reader 0: Generic USB2.0-CRW [Smart Card Reader Interface] (2007[redigido]) 00 00
  Event number: 2
  Card state: **Card inserted,** 
  ATR: 3B FF _[redigido]_ D0    

Mesmo assim, correndo o programa, seja em flatpak ou em binário, diz "Erro, leitor de cartões não detectado"...

@cristianojesus
Copy link

Há alguma solução para essa situação? Estou com esse mesmo problema. Estou a utilizar Ubuntu 24.10. A aplicação de Autenticação não reconhece o leitor do cartão, embora com o comando pcsc_scan funcione perfeitamente.

@jgrocha
Copy link

jgrocha commented Jan 2, 2025

Há alguma solução para essa situação? Estou com esse mesmo problema. Estou a utilizar Ubuntu 24.10. A aplicação de Autenticação não reconhece o leitor do cartão, embora com o comando pcsc_scan funcione perfeitamente.

@cristianojesus Parece-me que o problema no Ubuntu 24.10 deve-se a uma diferença de protocolos, já que as versões do pcscd do Ubuntu 24.10 e a versão do pcscd-lite que vem no flatpak usam versões diferentes do protocolo. Reportei no issue #194. A alternativa mais fácil parece-me ser compilar a aplicação no Ubuntu 24.10.

Compilei a aplicação no Ubuntu 24.10 e corre bem (excepto o suporte a atributos profissionais ou empresariais, como reportei em #195).

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

3 participants