Permalink
Browse files

Ask for all slots before asking for slot

OpenSC with certain card(s) requires this call to make slots
visible.
  • Loading branch information...
1 parent 7821417 commit 8d56a31a76bf420287cf6df6b39abb00da9dfad3 @cmouse cmouse committed with cmouse Mar 29, 2015
Showing with 5 additions and 0 deletions.
  1. +5 −0 pdns/pkcs11signers.cc
@@ -641,6 +641,11 @@ boost::shared_ptr<Pkcs11Token> Pkcs11Token::GetToken(const std::string& module,
_CK_SLOT_INFO info;
unsigned long slots;
+ // this is required by certain tokens, otherwise C_GetSlotInfo will not return a token
+ err = functions->C_GetSlotList(CK_FALSE, NULL_PTR, &slots);
+ if (err)
+ L<<Logger::Warning<<"C_GetSlotList(CK_FALSE, NULL_PTR, &slots) = " << err << std::endl;
+
if ((err = functions->C_GetSlotInfo(slotId, &info))) {
throw PDNSException(std::string("Cannot find PKCS#11 slot ") + boost::lexical_cast<std::string>(slotId) + std::string(" on module ") + module + std::string(": error code ") + boost::lexical_cast<std::string>(err));
}

0 comments on commit 8d56a31

Please sign in to comment.