Re: Установка драйвера ifd-rutokens в docker

Доброго дня! Отличный топик, вангую что будет пользоваться спросом. Проблему с установкой ifd-rutokens решил костылем:

RUN dpkg --unpack /opt/tokugawa/ifd-rutokens_1.0.4_amd64.deb
RUN rm /var/lib/dpkg/info/ifd-rutokens.postinst
RUN dpkg --configure ifd-rutokens

но вариант прокинуть /run/udev в контейнер выглядит куда более адекватным, спасибо!

В целом pcsc_scan из контейнера видит устройство, но pkcs11-tool отказывается видеть сам токен в докере

# pkcs11-tool --module /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so -I
Cryptoki version 2.20
Manufacturer     OpenSC Project
Library          OpenSC smartcard framework (ver 0.19)
No slot with a token was found.

тоже самое с хост машины с теми же дровами:

# pkcs11-tool --module /usr/lib/x86_64-linux-gnu/opensc-pkcs11.so -I
Cryptoki version 2.20
Manufacturer     OpenSC Project
Library          OpenSC smartcard framework (ver 0.17)
Using slot 0 with a present token (0x0)

librtpkcs11ecp.so на обоих хостах ничего не нашел:

# pkcs11-tool --module /usr/lib/librtpkcs11ecp.so -I
Cryptoki version 2.20
Manufacturer     Aktiv Co.
Library          Rutoken ECP PKCS #11 library (ver 2.0)
No slot with a token was found.

Есть мысли в какую сторону можно копнуть?

Re: Установка драйвера ifd-rutokens в docker

дебаг pcscd во время вызова pkcs11-tool с модулем opensc-pkcs11.so в контейнере:

00000000 [139908789995456] debuglog.c:299:DebugLogSetLevel() debug level=debug
00000032 [139908789995456] debuglog.c:299:DebugLogSetLevel() debug level=debug
00000006 [139908789995456] debuglog.c:299:DebugLogSetLevel() debug level=debug
00000028 [139908789995456] debuglog.c:299:DebugLogSetLevel() debug level=debug
00000009 [139908789995456] debuglog.c:299:DebugLogSetLevel() debug level=debug
00000218 [139908789995456] configfile.l:284:DBGetReaderListDir() Parsing conf directory: /etc/reader.conf.d
00000030 [139908789995456] configfile.l:321:DBGetReaderListDir() Skipping non regular file: .
00000011 [139908789995456] configfile.l:321:DBGetReaderListDir() Skipping non regular file: ..
00000010 [139908789995456] configfile.l:360:DBGetReaderList() Parsing conf file: /etc/reader.conf.d/libccidtwin
00000071 [139908789995456] pcscdaemon.c:662:main() pcsc-lite 1.8.24 daemon ready.
00004433 [139908789995456] hotplug_libudev.c:297:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0001, path: /dev/bus/usb/001/001
00000203 [139908789995456] hotplug_libudev.c:297:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0001, path: /dev/bus/usb/001/001
00000211 [139908789995456] hotplug_libudev.c:297:get_driver() Looking for a driver for VID: 0x0E0F, PID: 0x0003, path: /dev/bus/usb/001/002
00000190 [139908789995456] hotplug_libudev.c:297:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0001, path: /dev/bus/usb/001/001
00000213 [139908789995456] hotplug_libudev.c:297:get_driver() Looking for a driver for VID: 0x0E0F, PID: 0x0002, path: /dev/bus/usb/001/003
00000234 [139908789995456] hotplug_libudev.c:297:get_driver() Looking for a driver for VID: 0x0A89, PID: 0x0020, path: /dev/bus/usb/001/004
00000014 [139908789995456] hotplug_libudev.c:436:HPAddDevice() Adding USB device: Aktiv Co. Rutoken S
00000083 [139908789995456] readerfactory.c:1075:RFInitializeReader() Attempting startup of Aktiv Co. Rutoken S 00 00 using /usr/lib/pcsc/drivers/ifd-rutokens.bundle/Contents/Linux/librutokens.so
00000206 [139908789995456] readerfactory.c:950:RFBindFunctions() Loading IFD Handler 3.0
00048120 [139908789995456] readerfactory.c:396:RFAddReader() Using the reader polling thread
00003848 [139908789995456] hotplug_libudev.c:297:get_driver() Looking for a driver for VID: 0x0E0F, PID: 0x0002, path: /dev/bus/usb/001/003
00000693 [139908789995456] hotplug_libudev.c:297:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0002, path: /dev/bus/usb/002/001
00000297 [139908789995456] readerfactory.c:1410:RFWaitForReaderInit() Waiting init for reader: Aktiv Co. Rutoken S 00 00
00010137 [139908777309952] eventhandler.c:289:EHStatusHandlerThread() powerState: POWER_STATE_POWERED
00000045 [139908777309952] Card ATR: 3B 6F 00 FF 00 56 72 75 54 6F 6B 6E 73 30 20 00 00 90 00
02876978 [139908789995456] winscard_msg_srv.c:255:ProcessEventsServer() Common channel packet arrival
00000077 [139908789995456] winscard_msg_srv.c:267:ProcessEventsServer() ProcessCommonChannelRequest detects: 8
00000012 [139908789995456] pcscdaemon.c:133:SVCServiceRunLoop() A new context thread creation is requested: 8
00000300 [139908760524544] winscard_svc.c:340:ContextThread() Authorized PC/SC client
00000034 [139908760524544] winscard_svc.c:344:ContextThread() Thread is started: dwClientID=8, threadContext @0x55ed6920f330
00000046 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_VERSION from client 8
00000009 [139908760524544] winscard_svc.c:374:ContextThread() Client is protocol version 4:4
00000006 [139908760524544] winscard_svc.c:394:ContextThread() CMD_VERSION rv=0x0 for client 8
00000362 [139908760524544] winscard_svc.c:362:ContextThread() Received command: ESTABLISH_CONTEXT from client 8
00000037 [139908760524544] winscard.c:215:SCardEstablishContext() Establishing Context: 0x44E588A
00000011 [139908760524544] winscard_svc.c:459:ContextThread() ESTABLISH_CONTEXT rv=0x0 for client 8
00000080 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_GET_READERS_STATE from client 8
00000176 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_GET_READERS_STATE from client 8
00000260 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_WAIT_READER_STATE_CHANGE from client 8
00000110 [139908760524544] winscard_svc.c:832:MSGSendReaderStates() Send reader states: 8
00000217 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_STOP_WAITING_READER_STATE_CHANGE from client 8
00000021 [139908760524544] winscard_svc.c:440:ContextThread() CMD_STOP_WAITING_READER_STATE_CHANGE rv=0x0 for client 8
00000123 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CONNECT from client 8
00000016 [139908760524544] winscard_svc.c:497:ContextThread() Authorized client for 'Aktiv Co. Rutoken S 00 00'
00000005 [139908760524544] winscard.c:259:SCardConnect() Attempting Connect to Aktiv Co. Rutoken S 00 00 using protocol: 3
00000006 [139908760524544] readerfactory.c:821:RFReaderInfo() RefReader() count was: 1
00000005 [139908760524544] winscard.c:352:SCardConnect() powerState: POWER_STATE_IN_USE
00000006 [139908760524544] prothandler.c:108:PHSetProtocol() Attempting PTS to T=0
00000006 [139908760524544] winscard.c:431:SCardConnect() Active Protocol: T=0
00000005 [139908760524544] winscard.c:456:SCardConnect() hCard Identity: 3bb9a6db
00000013 [139908760524544] winscard.c:518:SCardConnect() UnrefReader() count was: 2
00000007 [139908760524544] winscard_svc.c:511:ContextThread() CONNECT rv=0x0 for client 8
00000096 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CONTROL from client 8
00000060 [139908760524544] readerfactory.c:848:RFReaderInfoById() RefReader() count was: 1
00000025 [139908760524544] winscard.c:1365:SCardControl() UnrefReader() count was: 2
00000017 [139908760524544] winscard_svc.c:733:ContextThread() CONTROL rv=0x0 for client 8
00000135 [139908760524544] winscard_svc.c:362:ContextThread() Received command: GET_ATTRIB from client 8
00000044 [139908760524544] readerfactory.c:848:RFReaderInfoById() RefReader() count was: 1
00000022 [139908760524544] winscard.c:1440:SCardGetAttrib() UnrefReader() count was: 2
00000023 [139908760524544] winscard_svc.c:762:ContextThread() GET_ATTRIB rv=0x0 for client 8
00000095 [139908760524544] winscard_svc.c:362:ContextThread() Received command: GET_ATTRIB from client 8
00000027 [139908760524544] readerfactory.c:848:RFReaderInfoById() RefReader() count was: 1
00000006 [139908760524544] winscard.c:1440:SCardGetAttrib() UnrefReader() count was: 2
00000023 [139908760524544] winscard_svc.c:762:ContextThread() GET_ATTRIB rv=0x0 for client 8
00000195 [139908760524544] winscard_svc.c:362:ContextThread() Received command: DISCONNECT from client 8
00000045 [139908760524544] readerfactory.c:848:RFReaderInfoById() RefReader() count was: 1
00000021 [139908760524544] winscard.c:884:SCardDisconnect() Active Contexts: 1
00000019 [139908760524544] winscard.c:885:SCardDisconnect() dwDisposition: 0
00000018 [139908760524544] winscard.c:1020:SCardDisconnect() powerState: POWER_STATE_GRACE_PERIOD
00000027 [139908760524544] winscard.c:1046:SCardDisconnect() UnrefReader() count was: 2
00000021 [139908760524544] winscard_svc.c:548:ContextThread() DISCONNECT rv=0x0 for client 8
00000207 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_WAIT_READER_STATE_CHANGE from client 8
00000029 [139908760524544] winscard_svc.c:832:MSGSendReaderStates() Send reader states: 8
00000149 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_STOP_WAITING_READER_STATE_CHANGE from client 8
00000031 [139908760524544] winscard_svc.c:440:ContextThread() CMD_STOP_WAITING_READER_STATE_CHANGE rv=0x0 for client 8
00000100 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_WAIT_READER_STATE_CHANGE from client 8
00000037 [139908760524544] winscard_svc.c:832:MSGSendReaderStates() Send reader states: 8
00000079 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_STOP_WAITING_READER_STATE_CHANGE from client 8
00000025 [139908760524544] winscard_svc.c:440:ContextThread() CMD_STOP_WAITING_READER_STATE_CHANGE rv=0x0 for client 8
00000079 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_WAIT_READER_STATE_CHANGE from client 8
00000013 [139908760524544] winscard_svc.c:832:MSGSendReaderStates() Send reader states: 8
00000074 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_STOP_WAITING_READER_STATE_CHANGE from client 8
00000010 [139908760524544] winscard_svc.c:440:ContextThread() CMD_STOP_WAITING_READER_STATE_CHANGE rv=0x0 for client 8
00000079 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_WAIT_READER_STATE_CHANGE from client 8
00000018 [139908760524544] winscard_svc.c:832:MSGSendReaderStates() Send reader states: 8
00000086 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_STOP_WAITING_READER_STATE_CHANGE from client 8
00000027 [139908760524544] winscard_svc.c:440:ContextThread() CMD_STOP_WAITING_READER_STATE_CHANGE rv=0x0 for client 8
00000091 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_WAIT_READER_STATE_CHANGE from client 8
00000029 [139908760524544] winscard_svc.c:832:MSGSendReaderStates() Send reader states: 8
00000152 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_STOP_WAITING_READER_STATE_CHANGE from client 8
00000038 [139908760524544] winscard_svc.c:440:ContextThread() CMD_STOP_WAITING_READER_STATE_CHANGE rv=0x0 for client 8
00000055 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_WAIT_READER_STATE_CHANGE from client 8
00000014 [139908760524544] winscard_svc.c:832:MSGSendReaderStates() Send reader states: 8
00000066 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_STOP_WAITING_READER_STATE_CHANGE from client 8
00000018 [139908760524544] winscard_svc.c:440:ContextThread() CMD_STOP_WAITING_READER_STATE_CHANGE rv=0x0 for client 8
00000046 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CONNECT from client 8
00000011 [139908760524544] winscard_svc.c:497:ContextThread() Authorized client for 'Aktiv Co. Rutoken S 00 00'
00000018 [139908760524544] winscard.c:259:SCardConnect() Attempting Connect to Aktiv Co. Rutoken S 00 00 using protocol: 3
00000006 [139908760524544] readerfactory.c:821:RFReaderInfo() RefReader() count was: 1
00000005 [139908760524544] winscard.c:352:SCardConnect() powerState: POWER_STATE_IN_USE
00000005 [139908760524544] winscard.c:431:SCardConnect() Active Protocol: T=0
00000005 [139908760524544] winscard.c:456:SCardConnect() hCard Identity: 6989683e
00000005 [139908760524544] winscard.c:518:SCardConnect() UnrefReader() count was: 2
00000005 [139908760524544] winscard_svc.c:511:ContextThread() CONNECT rv=0x0 for client 8
00000336 [139908760524544] winscard_svc.c:362:ContextThread() Received command: BEGIN_TRANSACTION from client 8
00000029 [139908760524544] readerfactory.c:848:RFReaderInfoById() RefReader() count was: 1
00000021 [139908760524544] winscard.c:1085:SCardBeginTransaction() Status: 0x00000000
00000026 [139908760524544] winscard.c:1088:SCardBeginTransaction() UnrefReader() count was: 2
00000018 [139908760524544] winscard_svc.c:563:ContextThread() BEGIN_TRANSACTION rv=0x0 for client 8
00000083 [139908760524544] winscard_svc.c:362:ContextThread() Received command: TRANSMIT from client 8
00000018 [139908760524544] readerfactory.c:848:RFReaderInfoById() RefReader() count was: 1
00000005 [139908760524544] winscard.c:1601:SCardTransmit() Send Protocol: T=0
00000007 [139908760524544] APDU: 00 A4 08 00 02 00 2F
00197927 [139908760524544] SW: 6A 82
00000117 [139908760524544] winscard.c:1646:SCardTransmit() UnrefReader() count was: 2
00000038 [139908760524544] winscard_svc.c:683:ContextThread() TRANSMIT rv=0x0 for client 8
00000364 [139908760524544] winscard_svc.c:362:ContextThread() Received command: END_TRANSACTION from client 8
00000080 [139908760524544] readerfactory.c:848:RFReaderInfoById() RefReader() count was: 1
00000036 [139908760524544] winscard.c:1240:SCardEndTransaction() Status: 0x00000000
00000039 [139908760524544] winscard.c:1243:SCardEndTransaction() UnrefReader() count was: 2
00000062 [139908760524544] winscard_svc.c:579:ContextThread() END_TRANSACTION rv=0x0 for client 8
00009059 [139908760524544] winscard_svc.c:362:ContextThread() Received command: BEGIN_TRANSACTION from client 8
00000062 [139908760524544] readerfactory.c:848:RFReaderInfoById() RefReader() count was: 1
00000013 [139908760524544] winscard.c:1085:SCardBeginTransaction() Status: 0x00000000
00000009 [139908760524544] winscard.c:1088:SCardBeginTransaction() UnrefReader() count was: 2
00000014 [139908760524544] winscard_svc.c:563:ContextThread() BEGIN_TRANSACTION rv=0x0 for client 8
00000446 [139908760524544] winscard_svc.c:362:ContextThread() Received command: TRANSMIT from client 8
00000027 [139908760524544] readerfactory.c:848:RFReaderInfoById() RefReader() count was: 1
00000010 [139908760524544] winscard.c:1601:SCardTransmit() Send Protocol: T=0
00000009 [139908760524544] APDU: 00 A4 08 00 02 15 50
00033258 [139908760524544] SW: 6A 82
00000089 [139908760524544] winscard.c:1646:SCardTransmit() UnrefReader() count was: 2
00000037 [139908760524544] winscard_svc.c:683:ContextThread() TRANSMIT rv=0x0 for client 8
00000332 [139908760524544] winscard_svc.c:362:ContextThread() Received command: TRANSMIT from client 8
00000108 [139908760524544] readerfactory.c:848:RFReaderInfoById() RefReader() count was: 1
00000062 [139908760524544] winscard.c:1601:SCardTransmit() Send Protocol: T=0
00000064 [139908760524544] APDU: 00 A4 08 00 02 31 50
00030688 [139908760524544] SW: 6A 82
00000042 [139908760524544] winscard.c:1646:SCardTransmit() UnrefReader() count was: 2
00000014 [139908760524544] winscard_svc.c:683:ContextThread() TRANSMIT rv=0x0 for client 8
00000505 [139908760524544] winscard_svc.c:362:ContextThread() Received command: END_TRANSACTION from client 8
00000048 [139908760524544] readerfactory.c:848:RFReaderInfoById() RefReader() count was: 1
00000013 [139908760524544] winscard.c:1240:SCardEndTransaction() Status: 0x00000000
00000009 [139908760524544] winscard.c:1243:SCardEndTransaction() UnrefReader() count was: 2
00000009 [139908760524544] winscard_svc.c:579:ContextThread() END_TRANSACTION rv=0x0 for client 8
00005025 [139908760524544] winscard_svc.c:362:ContextThread() Received command: DISCONNECT from client 8
00000038 [139908760524544] readerfactory.c:848:RFReaderInfoById() RefReader() count was: 1
00000011 [139908760524544] winscard.c:884:SCardDisconnect() Active Contexts: 1
00000008 [139908760524544] winscard.c:885:SCardDisconnect() dwDisposition: 0
00000010 [139908760524544] winscard.c:1020:SCardDisconnect() powerState: POWER_STATE_GRACE_PERIOD
00000010 [139908760524544] winscard.c:1046:SCardDisconnect() UnrefReader() count was: 2
00000042 [139908760524544] winscard_svc.c:548:ContextThread() DISCONNECT rv=0x0 for client 8
00000363 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_GET_READERS_STATE from client 8
00000426 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_GET_READERS_STATE from client 8
00000376 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_WAIT_READER_STATE_CHANGE from client 8
00000052 [139908760524544] winscard_svc.c:832:MSGSendReaderStates() Send reader states: 8
00000200 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_STOP_WAITING_READER_STATE_CHANGE from client 8
00000056 [139908760524544] winscard_svc.c:440:ContextThread() CMD_STOP_WAITING_READER_STATE_CHANGE rv=0x0 for client 8
00000267 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_WAIT_READER_STATE_CHANGE from client 8
00000048 [139908760524544] winscard_svc.c:832:MSGSendReaderStates() Send reader states: 8
00000156 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_STOP_WAITING_READER_STATE_CHANGE from client 8
00000045 [139908760524544] winscard_svc.c:440:ContextThread() CMD_STOP_WAITING_READER_STATE_CHANGE rv=0x0 for client 8
00000314 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_WAIT_READER_STATE_CHANGE from client 8
00000049 [139908760524544] winscard_svc.c:832:MSGSendReaderStates() Send reader states: 8
00000153 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_STOP_WAITING_READER_STATE_CHANGE from client 8
00000047 [139908760524544] winscard_svc.c:440:ContextThread() CMD_STOP_WAITING_READER_STATE_CHANGE rv=0x0 for client 8
00000309 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_WAIT_READER_STATE_CHANGE from client 8
00000045 [139908760524544] winscard_svc.c:832:MSGSendReaderStates() Send reader states: 8
00000315 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_STOP_WAITING_READER_STATE_CHANGE from client 8
00000046 [139908760524544] winscard_svc.c:440:ContextThread() CMD_STOP_WAITING_READER_STATE_CHANGE rv=0x0 for client 8
00000168 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_WAIT_READER_STATE_CHANGE from client 8
00000044 [139908760524544] winscard_svc.c:832:MSGSendReaderStates() Send reader states: 8
00000229 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_STOP_WAITING_READER_STATE_CHANGE from client 8
00000072 [139908760524544] winscard_svc.c:440:ContextThread() CMD_STOP_WAITING_READER_STATE_CHANGE rv=0x0 for client 8
00000146 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_WAIT_READER_STATE_CHANGE from client 8
00000044 [139908760524544] winscard_svc.c:832:MSGSendReaderStates() Send reader states: 8
00000339 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_STOP_WAITING_READER_STATE_CHANGE from client 8
00000046 [139908760524544] winscard_svc.c:440:ContextThread() CMD_STOP_WAITING_READER_STATE_CHANGE rv=0x0 for client 8
00000335 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_WAIT_READER_STATE_CHANGE from client 8
00000047 [139908760524544] winscard_svc.c:832:MSGSendReaderStates() Send reader states: 8
00000343 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_STOP_WAITING_READER_STATE_CHANGE from client 8
00000048 [139908760524544] winscard_svc.c:440:ContextThread() CMD_STOP_WAITING_READER_STATE_CHANGE rv=0x0 for client 8
00000444 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_WAIT_READER_STATE_CHANGE from client 8
00000046 [139908760524544] winscard_svc.c:832:MSGSendReaderStates() Send reader states: 8
00000140 [139908760524544] winscard_svc.c:362:ContextThread() Received command: CMD_STOP_WAITING_READER_STATE_CHANGE from client 8
00000044 [139908760524544] winscard_svc.c:440:ContextThread() CMD_STOP_WAITING_READER_STATE_CHANGE rv=0x0 for client 8
00000316 [139908760524544] winscard_svc.c:362:ContextThread() Received command: RELEASE_CONTEXT from client 8
00000027 [139908760524544] winscard.c:229:SCardReleaseContext() Releasing Context: 0x44E588A
00000025 [139908760524544] winscard_svc.c:474:ContextThread() RELEASE_CONTEXT rv=0x0 for client 8
00000291 [139908760524544] winscard_svc.c:354:ContextThread() Client die: 8
00000074 [139908760524544] winscard_svc.c:1057:MSGCleanupClient() Thread is stopping: dwClientID=8, threadContext @0x55ed6920f330
00000039 [139908760524544] winscard_svc.c:1063:MSGCleanupClient() Freeing SCONTEXT @0x55ed6920f330

Re: Установка драйвера ifd-rutokens в docker

Добрый день,

Если вы используете Рутокен S, то librtpkcs11ecp.so и  opensc-pkcs11.so его не увидят. Это нормально.
Эти библиотека только с ECP-подобными-токенами работают, в которых криптография реализована.

Ошибка 6A82 - "файл не найден" именно об этом говорит.

С уважением, Алексей Лазарев, Компания "Актив"

(2025-01-20 14:30:45 отредактировано Алексей Вдовин)

Re: Установка драйвера ifd-rutokens в docker

Проблема один в один как у Алексея Черенцова.

за базу взял образ на базе Ubuntu c 21 jdk
eclipse-temurin:21.0.2_13-jdk-jammy

#uname -a
Linux alex-dev 6.8.0-51-generic #52-Ubuntu SMP PREEMPT_DYNAMIC Thu Dec  5 13:09:44 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux root@alex-dev:~#

запускаю с учетом вышенаписанных рекомендаций (dockec compose)
    privileged: true
    network_mode: host
    volumes:
      - "/dev/bus/usb:/dev/bus/usb:ro"
      - "/run/udev:/run/udev:ro"

При сборке доустанавливаю следующие пакеты
RUN apt-get update && apt-get install -y usbutils udev libusb-0.1-4 libccid pcscd libpcsclite1 pcsc-tools dialog opensc debconf

далее если в лоб ставить драйвера
RUN dpkg -i ifd-rutokens_1.0.4_amd64.deb
не ставятся и образ не собирается

> [signer stage-1  5/10] RUN dpkg -i ifd-rutokens_1.0.4_amd64.deb:
0.107 Selecting previously unselected package ifd-rutokens.
0.114 (Reading database ... 27718 files and directories currently installed.)
0.114 Preparing to unpack ifd-rutokens_1.0.4_amd64.deb ...
0.116 Unpacking ifd-rutokens (1.0.4) ...
0.134 Setting up ifd-rutokens (1.0.4) ...
0.142 Failed to send reload request: No such file or directory
0.142 dpkg: error processing package ifd-rutokens (--install):
0.142  installed ifd-rutokens package post-installation script subprocess returned error exit status 1
0.146 Errors were encountered while processing:
0.146  ifd-rutokens
------
failed to solve: process "/bin/sh -c dpkg -i ifd-rutokens_1.0.4_amd64.deb" did not complete successfully: exit code: 1

поэтому поставил по совету oleg_jpeg

RUN dpkg --unpack ifd-rutokens_1.0.4_amd64.deb
RUN rm /var/lib/dpkg/info/ifd-rutokens.postinst
RUN dpkg --configure ifd-rutokens

потом в запущенном контейнере проверил
dpkg -l | grep ifd-rutokens
пакет установлен

далее в контейнере
/etc/init.d/pcscd start
pcsc_scan

даёт

Using reader plug'n play mechanism
Scanning present readers...
Waiting for the first reader... -

смотрю в режиме отладки - так же ошибка

/etc/init.d/pcscd stop
pcscd -afddddd

00000000 [137341524619776] debuglog.c:299:DebugLogSetLevel() debug level=debug
00000015 [137341524619776] debuglog.c:299:DebugLogSetLevel() debug level=debug
00000005 [137341524619776] debuglog.c:299:DebugLogSetLevel() debug level=debug
00000002 [137341524619776] debuglog.c:299:DebugLogSetLevel() debug level=debug
00000005 [137341524619776] debuglog.c:299:DebugLogSetLevel() debug level=debug
00000179 [137341524619776] configfile.l:293:DBGetReaderListDir() Parsing conf directory: /etc/reader.conf.d
00000020 [137341524619776] configfile.l:329:DBGetReaderListDir() Skipping non regular file: ..
00000004 [137341524619776] configfile.l:329:DBGetReaderListDir() Skipping non regular file: .
00000005 [137341524619776] configfile.l:369:DBGetReaderList() Parsing conf file: /etc/reader.conf.d/libccidtwin
00000042 [137341524619776] pcscdaemon.c:663:main() pcsc-lite 1.9.5 daemon ready.
00004771 [137341524619776] hotplug_libudev.c:300:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0002, path: /dev/bus/usb/001/001
00000140 [137341524619776] hotplug_libudev.c:300:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0002, path: /dev/bus/usb/001/001
00000131 [137341524619776] hotplug_libudev.c:300:get_driver() Looking for a driver for VID: 0x046D, PID: 0xC077, path: /dev/bus/usb/001/002
00000133 [137341524619776] hotplug_libudev.c:300:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0002, path: /dev/bus/usb/001/001
00000153 [137341524619776] hotplug_libudev.c:300:get_driver() Looking for a driver for VID: 0x0A89, PID: 0x0020, path: /dev/bus/usb/001/008
00000010 [137341524619776] hotplug_libudev.c:441:HPAddDevice() Adding USB device: Aktiv Co. Rutoken S
00000034 [137341524619776] readerfactory.c:1097:RFInitializeReader() Attempting startup of Aktiv Co. Rutoken S 00 00 using /usr/lib/pcsc/drivers/ifd-rutokens.bundle/Contents/Linux/librutokens.so
00000298 [137341524619776] readerfactory.c:972:RFBindFunctions() Loading IFD Handler 3.0
00110985 [137341524619776] readerfactory.c:1138:RFInitializeReader() Open Port 0x200000 Failed (usb:0a89)
00000013 [137341524619776] readerfactory.c:380:RFAddReader() Aktiv Co. Rutoken S init failed.
00000006 [137341524619776] readerfactory.c:632:RFRemoveReader() UnrefReader() count was: 1
00000003 [137341524619776] readerfactory.c:1151:RFUnInitializeReader() Attempting shutdown of Aktiv Co. Rutoken S 00 00.
00000006 [137341524619776] readerfactory.c:1009:RFUnloadReader() Unloading reader driver.
00000083 [137341524619776] hotplug_libudev.c:538:HPAddDevice() Failed adding USB device: Aktiv Co. Rutoken S
00000163 [137341524619776] hotplug_libudev.c:300:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0002, path: /dev/bus/usb/001/001
00000118 [137341524619776] hotplug_libudev.c:300:get_driver() Looking for a driver for VID: 0x04F2, PID: 0x0116, path: /dev/bus/usb/001/003
00000094 [137341524619776] hotplug_libudev.c:300:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0002, path: /dev/bus/usb/001/001
00000100 [137341524619776] hotplug_libudev.c:300:get_driver() Looking for a driver for VID: 0x8086, PID: 0x0808, path: /dev/bus/usb/001/004
00000111 [137341524619776] hotplug_libudev.c:300:get_driver() Looking for a driver for VID: 0x8086, PID: 0x0808, path: /dev/bus/usb/001/004
00000101 [137341524619776] hotplug_libudev.c:300:get_driver() Looking for a driver for VID: 0x8086, PID: 0x0808, path: /dev/bus/usb/001/004
00000171 [137341524619776] hotplug_libudev.c:300:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0003, path: /dev/bus/usb/002/001
00000210 [137341524619776] hotplug_libudev.c:300:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0002, path: /dev/bus/usb/003/001
00000210 [137341524619776] hotplug_libudev.c:300:get_driver() Looking for a driver for VID: 0x1D6B, PID: 0x0003, path: /dev/bus/usb/004/001


только одно НО - у Алексея в итоге с сетью host запустилось - у меня никак :(

ещё - момент с сетью непонятен, важно чтобы сеть оставалась та, что задана
сервис общается с БД и другими сервисами, которые именно в сети которую я задал в настройках ...

Re: Установка драйвера ifd-rutokens в docker

для чистоты эксперимента запустил контейнер из образа, такой же командой как было написано выше

docker run -it --privileged --volume=/dev/bus/usb:/dev/bus/usb:ro --volume=/run/udev:/run/udev:ro -e DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --publish=8083:8081 --network=host --rm=true bitrix-common-signer

ничего не изменилось - всё так же pcsc_scan не видит рутокен

(2025-01-20 17:46:09 отредактировано Евгений Мироненко)

Re: Установка драйвера ifd-rutokens в docker

gthack, добрый день!

Не уверен, что это вполне соответствует вашим ожиданиям, но рискну предложить. Насколько вам критично пробрасывать Рутокен S на уровне usb? Для взаимодействия с токеном, используя libpcsclite, достаточно пробросить в docker-образ сокет pcscd. Драйвер Рутокен S тогда придется установить на хост (не в образ).

Фактически, при этом установка пакетов в docker-образе сократится до такого:

RUN apt-get update && apt-get install -y libpcsclite1 pcsc-tools dialog opensc debconf

А при запуске необходимо указать подключение директории, содержащей сокет pcscd:

docker run -v /var/run/pcscd:/var/run/pcscd ...

libpcsclite в запущенном docker-образе будет общаться с pcscd, запущенным на хосте через проброшенный сокет /var/run/pcscd/pcscd.comm.

Re: Установка драйвера ifd-rutokens в docker

Евгений Мироненко, предложенный Вами вариант вполне устраивает - на уровне usb пробрасывать не критично.

Попробовал реализовать - не взлетает.

root@8054557cd79e:~# pcscd -afddddd
00000000 [136645612843520] debuglog.c:299:DebugLogSetLevel() debug level=debug
00000014 [136645612843520] debuglog.c:299:DebugLogSetLevel() debug level=debug
00000015 [136645612843520] debuglog.c:299:DebugLogSetLevel() debug level=debug
00000015 [136645612843520] debuglog.c:299:DebugLogSetLevel() debug level=debug
00000011 [136645612843520] debuglog.c:299:DebugLogSetLevel() debug level=debug
00000047 [136645612843520] pcscdaemon.c:482:main() file /run/pcscd/pcscd.comm already exists.
00000034 [136645612843520] pcscdaemon.c:484:main() Another pcscd (pid: 24) seems to be running.

(Вчера 12:08:05 отредактировано Евгений Мироненко)

Re: Установка драйвера ifd-rutokens в docker

Алексей Вдовин, это ожидаемое поведение. pcscd внутри docker-контейнера запускать не надо. Попробуйте без запуска pcscd запустить pcsc_scan.
Единственное, мы сталкивались с проблемой, что внутри docker-контейнера pcscd.comm (и, соответственно, доступ к смарт-картам) был доступен только из-под root (воспроизводилась проблема на ubuntu 24.04, не воспроизводилась на 22.04).

Re: Установка драйвера ifd-rutokens в docker

Евгений Мироненко пишет:

Попробуйте без запуска pcscd запустить pcsc_scan.

root@9793032ff1d3:~# pcsc_scan
SCardEstablishContext: Service not available.

(Вчера 14:23:45 отредактировано Алексей Вдовин)

Re: Установка драйвера ifd-rutokens в docker

Евгений Мироненко пишет:

Единственное, мы сталкивались с проблемой, что внутри docker-контейнера pcscd.comm (и, соответственно, доступ к смарт-картам) был доступен только из-под root (воспроизводилась проблема на ubuntu 24.04, не воспроизводилась на 22.04)

у меня как раз внутри от рута работает сейчас - так что хотя бы так запустить

не очень правильно, но от КриптоПро я так и не дождался как победить этот момент (в контейнере JCP приложение крутится)

на данный момент приложение вообще RutokenStore не видит - пока вот раскопки привели к тому, что для начала pcsc_scan должен устройство видеть ...

Re: Установка драйвера ifd-rutokens в docker

Алексей Вдовин, на всякий случай продемонстрирую, что у меня такая же нога, но не болит.  Возможно, вы найдете расхождения со своим экспериментом.

На хосте установлены pcscd, libpcsclite1, pcsc-tools.

mironenko@mironenko-ubuntu2204:~/forum$ uname -a
Linux mironenko-ubuntu2204 6.8.0-40-generic #40~22.04.3-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 30 17:30:19 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

mironenko@mironenko-ubuntu2204:~/forum$ docker --version
Docker version 24.0.7, build 24.0.7-0ubuntu2~22.04.1

mironenko@mironenko-ubuntu2204:~/forum$ pcsc_scan
Using reader plug'n play mechanism
Scanning present readers...
0: ACS ACR 38U-CCID 00 00
 
Tue Jan 21 14:53:13 2025
 Reader 0: ACS ACR 38U-CCID 00 00
  Event number: 0
  Card state: Card inserted, 
  ATR: 3B 9C 97 80 11 40 52 75 74 6F 6B 65 6E 45 43 50 73 63 C0

ATR: 3B 9C 97 80 11 40 52 75 74 6F 6B 65 6E 45 43 50 73 63 C0
+ TS = 3B --> Direct Convention
+ T0 = 9C, Y(1): 1001, K: 12 (historical bytes)
  TA(1) = 97 --> Fi=512, Di=64, 8 cycles/ETU
    500000 bits/s at 4 MHz, fMax for Fi = 5 MHz => 625000 bits/s
  TD(1) = 80 --> Y(i+1) = 1000, Protocol T = 0 
-----
  TD(2) = 11 --> Y(i+1) = 0001, Protocol T = 1 
-----
  TA(3) = 40 --> IFSC: 64
+ Historical bytes: 52 75 74 6F 6B 65 6E 45 43 50 73 63
  Category indicator byte: 52 (proprietary format)
+ TCK = C0 (correct checksum)

Possibly identified card (using /usr/share/pcsc/smartcard_list.txt):
3B 9C 97 80 11 40 52 75 74 6F 6B 65 6E 45 43 50 73 63 C0
    Aktiv Rutoken ECP 3.0 NFC (PKI)
    https://www.rutoken.ru/products/all/rutoken-ecp-nfc/

Dockerfile:

ironenko@mironenko-ubuntu2204:~/forum$ cat Dockerfile 

FROM eclipse-temurin:21.0.2_13-jdk-jammy 
RUN apt-get update
RUN apt-get install -y wget libpcsclite1 pcsc-tools opensc

RUN apt-get -y install sudo adduser

RUN useradd -m user0 && echo "user0:Eklmn1516" | chpasswd && adduser user0 sudo

USER user0

WORKDIR /

Собираю, запускаю контейнер, подключаюсь к нему:

sudo docker build . --tag test-forum
sudo docker run -d  -t -v /var/run/pcscd:/var/run/pcscd --name test-forum test-forum 
sudo docker exec -it test-forum '/bin/bash'

pcsc_scan  внутри контейнера:

user0@6827d749a44e:/$ pcsc_scan
Using reader plug'n play mechanism
Scanning present readers...
0: ACS ACR 38U-CCID 00 00
 
Tue Jan 21 11:56:48 2025
 Reader 0: ACS ACR 38U-CCID 00 00
  Event number: 0
  Card state: Card inserted, 
  ATR: 3B 9C 97 80 11 40 52 75 74 6F 6B 65 6E 45 43 50 73 63 C0

ATR: 3B 9C 97 80 11 40 52 75 74 6F 6B 65 6E 45 43 50 73 63 C0
+ TS = 3B --> Direct Convention
+ T0 = 9C, Y(1): 1001, K: 12 (historical bytes)
  TA(1) = 97 --> Fi=512, Di=64, 8 cycles/ETU
    500000 bits/s at 4 MHz, fMax for Fi = 5 MHz => 625000 bits/s
  TD(1) = 80 --> Y(i+1) = 1000, Protocol T = 0 
-----
  TD(2) = 11 --> Y(i+1) = 0001, Protocol T = 1 
-----
  TA(3) = 40 --> IFSC: 64
+ Historical bytes: 52 75 74 6F 6B 65 6E 45 43 50 73 63
  Category indicator byte: 52 (proprietary format)
+ TCK = C0 (correct checksum)

Possibly identified card (using /usr/share/pcsc/smartcard_list.txt):
3B 9C 97 80 11 40 52 75 74 6F 6B 65 6E 45 43 50 73 63 C0
    Aktiv Rutoken ECP 3.0 NFC (PKI)
    https://www.rutoken.ru/products/all/rutoken-ecp-nfc/

Re: Установка драйвера ifd-rutokens в docker

заработало!
похоже чёт глюкнуло - ребутнул и всё заново так же запустил

root@7ce3530aa0c2:~# pcsc_scan
Using reader plug'n play mechanism
Scanning present readers...
0: Aktiv Co. Rutoken S 00 00

Спасибо огромное!
Пошел дальше смотреть, что там КриптоПро - увидит ли хранилище ...

Re: Установка драйвера ifd-rutokens в docker

Как оказалось, на Хабре есть статья с опытом, похожим на ваш: https://habr.com/ru/articles/706474/