From: Aki Tuomi Date: Tue, 20 Feb 2018 06:19:16 +0000 (+0200) Subject: pkcs11signers: Get actual slot IDs from PKCS#11 device X-Git-Tag: dnsdist-1.3.0~73^2~3 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d6d13132b1a8f8b410f33f2b241e028db7238db7;p=thirdparty%2Fpdns.git pkcs11signers: Get actual slot IDs from PKCS#11 device Some devices have slots that do not start from 0, so we ask for the slot IDs from the device and iterate those instead of just guessing the slot ID. --- diff --git a/pdns/pkcs11signers.cc b/pdns/pkcs11signers.cc index 045bae2b52..2ebe42e143 100644 --- a/pdns/pkcs11signers.cc +++ b/pdns/pkcs11signers.cc @@ -626,6 +626,7 @@ static std::map > pkcs11_tokens; CK_RV Pkcs11Slot::HuntSlot(const string& tokenId, CK_SLOT_ID &slotId, _CK_SLOT_INFO* info, CK_FUNCTION_LIST* functions) { CK_RV err; + unsigned int i; unsigned long slots; _CK_TOKEN_INFO tinfo; @@ -637,8 +638,19 @@ CK_RV Pkcs11Slot::HuntSlot(const string& tokenId, CK_SLOT_ID &slotId, _CK_SLOT_I return err; } + // get the actual slot ids + CK_SLOT_ID slotIds[slots]; + err = functions->C_GetSlotList(CK_FALSE, slotIds, &slots); + if (err) { + L<