17-03-2016 -> Metto la data in evidenza perchè, per esperienza, i sistemi allestiti da stato/regioni etc. cambiano in maniera repentina e non è detto che "domani" funzioni ancora tutto nello stesso modo.
Una doverosa premessa: mai mi sarei aspettato di riuscire ad accedere al portale dei servizi sanitari della Lombardia ( http://www.crs.regione.lombardia.it/sanita ), autenticandomi con la "nuova" ts-crs (quella blu)
tramite un lettore di smart card collegato a un pc con Centos 7. Invece, incrediblmente, è tutto semplicissimo (o ho avuto una botta di culo incredibile).
Primo link da guardare:
https://wiki.debian.org/Smartcards
Secondo link da guardare per farsi un po' di cultura sulle smart-card (che per me fino a un paio di anni fa erano degli oggetti misteriosi):
http://www.scardsoft.com/documents/COS/heng_guo.pdf
Il mio lettore di smart card è un vetusto SCM-SCR35xx.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
root@client:/root]# journalctl -f Mar 17 08:37:02 client kernel: usb 1-4: new full-speed USB device number 9 using xhci_hcd Mar 17 08:37:02 client kernel: usb 1-4: New USB device found, idVendor=04e6, idProduct=5410 Mar 17 08:37:02 client kernel: usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=5 Mar 17 08:37:02 client kernel: usb 1-4: Product: SCR35xx USB Smart Card Reader Mar 17 08:37:02 client kernel: usb 1-4: Manufacturer: SCM Microsystems Inc. Mar 17 08:37:02 client kernel: usb 1-4: SerialNumber: 21120622313434 Mar 17 08:37:02 client mtp-probe[29993]: checking bus 1, device 9: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-4" Mar 17 08:37:02 client mtp-probe[29993]: bus: 1, device: 9 was not an MTP device root@client:/root]# lsusb Bus 001 Device 009: ID 04e6:5410 SCM Microsystems, Inc. SCR35xx Smart Card Reader |
SCM Microsystems credo fosse una divisione di Siemens che ora ha un altro nome (o è stata venduta).
Windows (da 7 in avanti) cerca e trova online, tramite windows update, un driver per questo lettore in maniera automatica.
Qui su Centos 7 andremo a utilizzare libccid.
Vado a installare il pacchetto pcsc-lite
1 2 3 4 5 6 7 |
Description : The purpose of PC/SC Lite is to provide a Windows(R) SCard interface : in a very small form factor for communicating to smartcards and : readers. PC/SC Lite uses the same winscard API as used under : Windows(R). This package includes the PC/SC Lite daemon, a resource : manager that coordinates communications with smart card readers and : smart cards that are connected to the system, as well as other command : line tools. |
che mi va a installare pcsc-lite-ccid.
1 2 |
Description : Generic USB CCID (Chip/Smart Card Interface Devices) driver for use with the : PC/SC Lite daemon |
Avrò anche bisogno di opensc
1 2 3 4 5 6 7 |
Description : OpenSC provides a set of libraries and utilities to work with smart cards. Its : main focus is on cards that support cryptographic operations, and facilitate : their use in security applications such as authentication, mail encryption and : digital signatures. OpenSC implements the PKCS#11 API so applications : supporting this API (such as Mozilla Firefox and Thunderbird) can use it. On : the card OpenSC implements the PKCS#15 standard and aims to be compatible with : every software/card that does so, too. |
visto che la ts-crs deve proprio effettuare operazioni crittografiche.
Ora inserisco la smart-card nel lettore e mi assicuro che il demone pcscd.service sia attivo.
1 2 3 4 5 6 7 |
root@client:/root]# systemctl status pcscd.service -l ● pcscd.service - PC/SC Smart Card Daemon Loaded: loaded (/usr/lib/systemd/system/pcscd.service; indirect; vendor preset: disabled) Active: active (running) since Thu 2016-03-17 08:38:17 CET; 15s ago Main PID: 30049 (pcscd) CGroup: /system.slice/pcscd.service └─30049 /usr/sbin/pcscd --foreground --auto-exit |
Verifico con opensc-tool se vedo correttamente il lettore e la scheda in esso contenuta.
1 2 3 4 5 6 7 8 9 |
root@client:/root]# opensc-tool -l # Detected readers (pcsc) Nr. Card Features Name 0 Yes SCM Microsystems Inc. SCR35xx v2.0 USB SC Reader [CCID Interface] (21120622313434) 00 00 root@client:/root]# opensc-tool -n Using reader with a card: SCM Microsystems Inc. SCR35xx v2.0 USB SC Reader [CCID Interface] (21120622313434) 00 00 CNS card |
BINGO, sembra che funzioni tutto correttamente. Vediamo alla prova dei fatti.
Per prima cosa devo aggiungere a Firefox la libreria crittografica per leggere e gestire la smart-card. E' la stessa operazione che devo fare anche con Windows andando a pescare la dll Bit4p11.dll in Windows\System32 installata dal programma che chiamano "Software CRS o Software Postazione Lavoro".
Qui in Centos 7 la libreria si chiama opensc-pkcs11.so e opensc la installa in /usr/lib64/pkcs11/opensc-pkcs11.so.
1 2 |
root@client:/root]# rpm -qf /usr/lib64/pkcs11/opensc-pkcs11.so opensc-0.14.0-1.el7.x86_64 |
Con Firefox apro:
Preferences->Advanced->Certificates->Security Devices->Load
e poi effettuo il browse del file system andando a puntare al alla libreria di cui qui sopra.
Ora non mi resta che cliccare sul Accedi nel sito dei servizi sanitari online di regione Lombardia (http://www.crs.regione.lombardia.it/sanita) ed effettuare l'autenticazione con CRS o con TS-CNS, lettore di smart card e PIN.
Incredibilmente mi viene subito richiesto il PIN.
Scelgo il certificato all'interno della smart-card (in questo caso ne trovo solo 1 ma ce ne potrebbero essere anche di più in teoria su una smart-card)
e eseguo l'accesso.
Tutto questo in realtà è stato fatto solo perchè uno step per la richiesta del nuovo "spid" (http://www.spid.gov.it) richiede per il riconoscimento la ts-cns e il suo pin funzionanti.