您的位置:首页 > 运维架构 > Linux

Linux 平台下Libusb & ccid & pcsc-lite & OpenSC 通用安装步骤

2016-06-27 14:31 1381 查看
一、libusb 安装步骤:
1.下载安装包:
http://www.libusb.org/
2.解压安装包:
$ tar zxvf libusb-版本号.tar.gz

3.编译且安装:
$ cd libusb-版本号
$ ./configure
$ ./make
$ ./make install <- 要有 root 权限,Ubuntu 下可以 sudo ./make install

4.运行做测试:
$ lsusb
显示出如下类似信息则为安装成功
Bus 002 Device 002: ID 413c:2105 Dell Computer Corp. Model L100 Keyboard

二、ccid 安装步骤:
1.下载安装包:
http://pcsclite.alioth.debian.org
2.解压安装包:
$ tar jxvf ccid-版本号.tar.bz2

3.编译且安装:
$ cd ccid-版本号
$ ./configure

出现错误提示:
configure: error: usb.h not found, install libusb or use ./configure LIBUSB_CFLAGS=…

没有安装 libusb 。

$ ./make
$ ./make install <- 要有 root 权限,Ubuntu 下可以 sudo ./make install

如果 ccid 读卡器的 厂商ID 和产品ID 和 产品名称 不在 info.plist 文件中的话,
则添加它们在 <array> 列表的最后,因为这样 厂商ID 和 产品ID 和 产品名称就可以保证对应了:

如下例子的 厂商ID 和 产品ID 是 飞天诚信 的 Rocky 301 读卡器,
它已经在 ccid-1.4.5 中包含了,产品名称 一般是由 厂商名 加 型号名 组成的,
也可以任意起,只是不便于识别。(由于新浪博客的原因,请将如下 [] 改为 <>)

[key]ifdVendorID[/key]
[array]
...
[string]0x096E[/string]
[/array]



[key]ifdProductID[/key]
[array]
...
[string]0x0503[/string]
[/array]



[key]ifdFriendlyName[/key]
[array]
...
[string]Feitian SCR301[/string]
[/array]

info.plist 文件在 ubuntu 更新源安装时的路径:
/usr/local/lib/pcsc/drivers/ifd-ccid.bundle/Contents

info.plist 文件在 ubuntu 源代码安装时的路径:
/usr/local/pcsc/drivers/ifd-ccid.bundle/Contents

4.运行做测试:
在安装好 pcsc-lite 后一块做测试。

三、pcsc-lite 安装步骤:
1.下载安装包:
http://pcsclite.alioth.debian.org
2.解压安装包:
$ tar jxvf pcsc-lite-版本号.tar.bz2

3.编译且安装:
$ cd pcsc-lite-版本号
$ ./configure

出现类似错误提示:
configure: error: install libhal-dev or use --disable-libhal

可以选择安装 libhal 也可以用如下参数禁用它:
$ ./configure --disable-libhal

$ ./make
$ ./make install <- 要有 root 权限,Ubuntu 下可以 sudo ./make install

4.运行做测试:
$ /usr/local/sbin/pcscd -adf <- 要用 root 权限启动 pcscd 服务(前台运行且带输出信息)
显示出如下类似信息则为安装成功
00017575 pcscdaemon.c:518:main() pcsc-lite 1.8.1 daemon ready.

成功启动后,按 Ctrl + C 终止 pcscd 服务进程。

出现如下类似错误:
error while loading shared libraries:
libpkcs15init.so.2: cannot open shared object file: No such file or directory

$ sudo ldconfig <- 重新加载一下动态连接库的索引

出现如下类似错误:
00001001 hotplug_libhal.c:527:HPRegisterForHotplugEvents()
No bundle files in pcsc drivers directory: /usr/local/pcsc/drivers

没有安装 ccid 驱动。

四、 安装步骤:
1.下载安装包:
https://www.opensc-project.org/opensc
2.解压安装包:
$ tar zxvf opensc-版本号.tar.gz

3.编译且安装:
$ cd opensc-版本号
$ ./configure --enable-openssl --enable-pcsc

$ ./configure --enable-openssl --enable-pcsc --with-pcsc-provider=/usr/local/lib/libpcsclite.so
注:/usr/local/lib/libpcsclite.so 是举个例子,--with-pcsc-provider=/实际路径/libpcsclite.so
  不用 --with-pcsc-provider 参数指出的话,使用系统默认的。

出现错误提示:configure: error: xsl-stylesheets are required for svn build with man
$ ./configure --enable-openssl --enable-pcsc --disable-man

$ ./make
$ ./make install <- 要有 root 权限,Ubuntu 下可以 sudo ./make install

4.运行做测试:
$ opensc-tool --list-readers
显示出如下类似信息则为安装成功
# Detected readers (pcsc)
Nr. Card Features Name
0 No Feitian SCR301 00 00

$ opensc-tool --reader 0 --atr
显示出如下类似信息则为安装成功
3b:9f:95:81:31:fe:9f:00:65:46:53:05:30:06:71:df:00:00:00:80:00:00:b6
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息