智能卡
本页面解释了如何设置您的系统以使用智能卡读卡器。
安装
Failed to start pcscd.service: Unit pcscd.socket not found.
,只需使用 daemon-reload 重新加载 systemd 单元。OpenSC
OpenSC 提供了一组可选的库和实用程序,用于使用 pcsclite 的智能卡。
如果读卡器没有 PIN 码键盘,追加 行并设置 enable_pinpad = false
在 opensc 配置文件 /etc/opensc.conf
中。
配置
Mozilla Firefox
浏览器需要设置新的安全相关设备。打开安全设备页面(通过偏好设置 > 隐私与安全 > 证书 > 安全设备访问),然后单击加载并将模块名称设置为CAC 模块,模块文件名设置为 /usr/lib/opensc-pkcs11.so
。
Chromium
Chromium 使用 NSS。在您的主目录中打开一个 shell 并验证CAC 模块是否尚未存在
$ modutil -list -dbdir $HOME/.pki/nssdb/
Listing of PKCS #11 Modules ----------------------------------------------------------- 1. NSS Internal PKCS #11 Module ....
如果不存在,关闭所有浏览器并添加模块(需要用户交互进行确认)
$ modutil -dbdir sql:$HOME/.pki/nssdb/ -add "CAC Module" -libfile /usr/lib/opensc-pkcs11.so
WARNING: Performing this operation while the browser is running could cause corruption of your security databases. If the browser is currently running, you should exit browser before continuing this operation. Type 'q <enter>' to abort, or <enter> to continue: Module "CAC Module" added to database.
检查命令是否正确执行
$ modutil -list -dbdir $HOME/.pki/nssdb/
Listing of PKCS #11 Modules ----------------------------------------------------------- 1. NSS Internal PKCS #11 Module .... 2. CAC Module library name: /usr/lib/opensc-pkcs11.so uri: pkcs11:library-manufacturer=OpenSC%20Project;library-description=OpenSC%20smartcard%20framework;library-version=0.19 slots: 1 slot attached status: loaded
技巧与窍门
扫描读卡器和卡片
安装 pcsc-tools 并启动 pcsc_scan(1) 实用程序,然后连接智能卡读卡器,最后插入卡片。如果您看到类似这样的输出,则智能卡读卡器和卡片都已成功识别。
$ pcsc_scan
PC/SC device scanner V 1.5.2 (c) 2001-2017, Ludovic Rousseau <ludovic.rousseau@free.fr> Using reader plug'n play mechanism Scanning present readers... 0: Alcor Micro AU9560 00 00 Sat Aug 5 18:49:32 2017 Reader 0: Alcor Micro AU9560 00 00 Card state: Card removed, Sat Aug 5 19:00:35 2017 Reader 0: Alcor Micro AU9560 00 00 Card state: Card inserted, ATR: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF ATR: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF + TS = 3B --> Direct Convention + T0 = DF, Y(1): 1101, K: 15 (historical bytes) TA(1) = 18 --> Fi=372, Di=12, 31 cycles/ETU 129032 bits/s at 4 MHz, fMax for Fi = 5 MHz => 161290 bits/s 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) = 7D --> Block Waiting Integer: 7 - Character Waiting Integer: 13 + Historical bytes: 00 6B 02 0C 01 82 01 11 01 43 4E 53 10 31 80 Category indicator byte: 00 (compact TLV data object) Tag: 6, len: B (pre-issuing data) Data: FF FF FF FF FF FF FF FF FF FF Mandatory status indicator (3 last bytes) LCS (life card cycle): 10 (Proprietary) SW: 3180 (Error not defined by ISO 7816) + TCK = FC (correct checksum) Possibly identified card (using /usr/share/pcsc/smartcard_list.txt): FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF Italian healtcare card (TS) National Service Card (CNS) (HealthCare)
Smargo/TV 卡读卡器
当与电视卡接口进行直播电视和录制 (PVR/DVR) 时,您可能需要将智能卡读卡器分配给 video
用户组 以允许解密。当使用 Smargo Smartreader 时,请考虑以下 udev 规则
/etc/udev/rules.d/98-smargo.rules
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", GROUP="video", MODE="0666", SYMLINK+="smargo"
当使用 OSCam 等软卡应用程序时,将 /dev/smargo
设置为读卡器设备。
p11tool
如果使用来自 GnuTLS 套件的包,这些包使用 p11-kit,例如 p11tool,则 OpenSC 驱动程序可能无法正确加载。如果您运行 p11tool --list-tokens
并且在列表中没有看到您的硬件令牌,则可以确定这一点。
安装 opensc-p11-kit-moduleAUR 软件包,以启用 OpenSC 模块的加载。
或者,可以手动创建一个文件,允许正确加载 OpenSC 驱动程序
/usr/share/p11-kit/modules/opensc.module
module: opensc-pkcs11.so
SafeNet eToken
来自 ThalesGroup 的令牌和智能卡类别。被 Certisign 等公司使用。
安装 sac-coreAUR 到 pkcs11 库安装。
SafeNet eToken 在 Google Chrome 上
模块需要添加到 nssdb
$ modutil -dbdir sql:.pki/nssdb/ -add "eToken" -libfile /usr/lib/libeToken.so
WARNING: Performing this operation while the browser is running could cause corruption of your security databases. If the browser is currently running, you should exit browser before continuing this operation. Type 'q <enter>' to abort, or <enter> to continue: Module "eToken" added to database.
确认已安装
$ modutil -dbdir sql:.pki/nssdb/ -list
Listing of PKCS #11 Modules
1. NSS Internal PKCS #11 Module uri: pkcs11:library-manufacturer=Mozilla%20Foundation;library-description=NSS%20Internal%20Crypto%20Services;library-version=3.98 slots: 2 slots attached status: loaded slot: NSS Internal Cryptographic Services token: NSS Generic Crypto Services uri: pkcs11:token=NSS%20Generic%20Crypto%20Services;manufacturer=Mozilla%20Foundation;serial=0000000000000000;model=NSS%203 slot: NSS User Private Key and Certificate Services token: NSS Certificate DB uri: pkcs11:token=NSS%20Certificate%20DB;manufacturer=Mozilla%20Foundation;serial=0000000000000000;model=NSS%203 2. eToken library name: /usr/lib/libeToken.so uri: pkcs11:library-manufacturer=SafeNet,%20Inc.;library-description=SafeNet%20eToken%20PKCS%2311;library-version=10.8 slots: 8 slots attached status: loaded slot: Gemalto PC Twin Reader 00 00 token: eCPF Certisign uri: pkcs11:token=eCPF%20Certisign;manufacturer=Gemalto;serial=AF3E411BD8A8E169;model=ID%20Prime%20MD slot: token: uri: pkcs11: slot: token: uri: pkcs11: slot: token: uri: pkcs11: slot: token: uri: pkcs11: slot: token: uri: pkcs11: slot: token: uri: pkcs11: slot: token: uri: pkcs11:
故障排除
Firefox 无法访问数据
如果浏览器无法使用智能卡数据,则可能是它不知道提供设备访问权限的服务。如果您在打开 Firefox 后插入智能卡读卡器,则会发生这种情况。要解决此问题,只需重启 Firefox 即可。
LIBUSB_ERROR_BUSY
PC/SC 可能会与 GnuPG 冲突,以访问智能卡。请参阅 Ludovic Rousseau 的博客 和 GnuPG#GnuPG 与 pcscd (PCSC Lite)。