From cac66974daf96110bfd707ea52563ecf66acfebf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20W=C3=A4ckerlin?= Date: Thu, 11 Dec 2014 09:06:51 +0000 Subject: [PATCH] another work around the mac 10.10 yosemite PCSC bug, this time fix cryptoki; refs #34 --- m4/ax_check_qt.m4 | 2 +- src/suisseid.hxx | 50 +++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/m4/ax_check_qt.m4 b/m4/ax_check_qt.m4 index 9e99aa2..19383c6 100644 --- a/m4/ax_check_qt.m4 +++ b/m4/ax_check_qt.m4 @@ -32,7 +32,7 @@ AC_DEFUN([AX_CXX_QT_TOOL], [ $1=${$1:-$(pkg-config --variable=host_bins Qt5Core)/$2} $1=${$1:-$(pkg-config --variable=$2_location QtCore)} $1=${$1:-$(pkg-config --variable=host_bins QtCore)/$2} - if ! which "$$1" > /dev/null; then + if ! which "${$1%% *}" > /dev/null; then if which "$2" > /dev/null; then $1=$2 else diff --git a/src/suisseid.hxx b/src/suisseid.hxx index 8a6aeff..22ce645 100644 --- a/src/suisseid.hxx +++ b/src/suisseid.hxx @@ -274,6 +274,13 @@ namespace suisseid { } virtual Certificate certificate(const std::string& keylabel) { +# 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). */ + static int applebug(0); +# endif CRYPTOLOG("get certificate for key "<attribute(CKA_ID)); - CRYPTOLOG("get certs for key with id "<(CKO_CERTIFICATE) <attribute(CKA_VALUE).value, - cert->attribute(CKA_LABEL).value, - id); +# 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). */ + try { +# endif + for (cryptoki::ObjectList::iterator cert(certs.begin()); + cert!=certs.end(); ++cert) // return first matching cert + return Certificate(cert->attribute(CKA_VALUE).value, + cert->attribute(CKA_LABEL).value, + id); +# 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). */ + } catch (std::exception& x) { + if (++applebug>1) { + CRYPTOLOG("failed again after apple bug retry with "<