workaround Mac OS X 10.10 PCSC bug; refs #34
This commit is contained in:
33
src/pcsc.hxx
33
src/pcsc.hxx
@@ -141,7 +141,7 @@ namespace pcsc {
|
||||
|
||||
//! @addtogroup pcsclib
|
||||
//@{
|
||||
|
||||
|
||||
//============================================================================
|
||||
class Connection {
|
||||
|
||||
@@ -306,11 +306,32 @@ namespace pcsc {
|
||||
rPci.cbPciLength = sizeof(rPci);
|
||||
// log only in verbose debuggung; could log pins
|
||||
CRYPTOLOG_VERBOSE("SCardTransmit: "<<crypto::hex(in));
|
||||
check(SCardTransmit(_id, &rPci,
|
||||
(LPCBYTE)in.c_str(),
|
||||
in.size(),
|
||||
0, buff, &len),
|
||||
"smartcard transmit message "+crypto::hex(in));
|
||||
try {
|
||||
check(SCardTransmit(_id, &rPci,
|
||||
(LPCBYTE)in.c_str(),
|
||||
in.size(),
|
||||
0, buff, &len),
|
||||
"smartcard transmit message "+crypto::hex(in));
|
||||
} catch (...) {
|
||||
// try to fix Apple's Mac OS X 10.10 implementation bug
|
||||
# ifdef __APPLE__
|
||||
/*! @bug Work around Mac OSX 10.10 bug. On Mac OSX
|
||||
10.10 there is a bug in PCSC: After a
|
||||
reconnect, first transaction (SCardTransmit)
|
||||
fails with SCARD_W_RESET_CARD
|
||||
(0x80100068). */
|
||||
if (_status==SCARD_W_RESET_CARD) { // just resend once
|
||||
check(SCardTransmit(_id, &rPci,
|
||||
(LPCBYTE)in.c_str(),
|
||||
in.size(),
|
||||
0, buff, &len),
|
||||
"smartcard transmit message "+crypto::hex(in));
|
||||
continue; // this time: success
|
||||
}
|
||||
# else
|
||||
throw; // just rethrow otherwise
|
||||
# endif
|
||||
}
|
||||
//CRYPTOLOG(" -> "<<crypto::hex(std::string((char*)buff, len)));
|
||||
return std::string((char*)buff, len);
|
||||
}
|
||||
|
Reference in New Issue
Block a user