Skip to content

Commit 8d56a31

Browse files
committed
Ask for all slots before asking for slot
OpenSC with certain card(s) requires this call to make slots visible.
1 parent 7821417 commit 8d56a31

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pdns/pkcs11signers.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,11 @@ boost::shared_ptr<Pkcs11Token> Pkcs11Token::GetToken(const std::string& module,
641641
_CK_SLOT_INFO info;
642642
unsigned long slots;
643643

644+
// this is required by certain tokens, otherwise C_GetSlotInfo will not return a token
645+
err = functions->C_GetSlotList(CK_FALSE, NULL_PTR, &slots);
646+
if (err)
647+
L<<Logger::Warning<<"C_GetSlotList(CK_FALSE, NULL_PTR, &slots) = " << err << std::endl;
648+
644649
if ((err = functions->C_GetSlotInfo(slotId, &info))) {
645650
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));
646651
}

0 commit comments

Comments
 (0)