workaround Mac OS X 10.10 PCSC bug; refs #34

master
Marc Wäckerlin 10 years ago
parent 0b4837d185
commit c871e3b2eb
  1. 31
      src/pcsc.hxx

@ -306,11 +306,32 @@ namespace pcsc {
rPci.cbPciLength = sizeof(rPci); rPci.cbPciLength = sizeof(rPci);
// log only in verbose debuggung; could log pins // log only in verbose debuggung; could log pins
CRYPTOLOG_VERBOSE("SCardTransmit: "<<crypto::hex(in)); CRYPTOLOG_VERBOSE("SCardTransmit: "<<crypto::hex(in));
check(SCardTransmit(_id, &rPci, try {
(LPCBYTE)in.c_str(), check(SCardTransmit(_id, &rPci,
in.size(), (LPCBYTE)in.c_str(),
0, buff, &len), in.size(),
"smartcard transmit message "+crypto::hex(in)); 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))); //CRYPTOLOG(" -> "<<crypto::hex(std::string((char*)buff, len)));
return std::string((char*)buff, len); return std::string((char*)buff, len);
} }

Loading…
Cancel
Save