]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Ask for all slots before asking for slot
authorAki Tuomi <cmouse@cmouse.fi>
Sun, 29 Mar 2015 15:57:23 +0000 (18:57 +0300)
committerAki Tuomi <cmouse@desteem.org>
Mon, 30 Mar 2015 07:30:26 +0000 (10:30 +0300)
OpenSC with certain card(s) requires this call to make slots
visible.

pdns/pkcs11signers.cc

index 52bc44616f53a0f1426a2ffa6ec9b5c5d3fa5122..fababbcd4ec31b8ca04fa4640982625276360b1d 100644 (file)
@@ -643,6 +643,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));
   }