Cannot find private match with certificate cka id / cka label

41 views
Skip to first unread message

kifle...@gmail.com

unread,
Feb 23, 2020, 10:53:49 PM2/23/20
to Pkcs11Interop
Hi guys, 

Im working on signing using private key in usb token which have multilple certificate inside it. So i need to get private key which match with the valid certificate...


List<ObjectAttribute> privateKeyAttributes = new List<ObjectAttribute>();
privateKeyAttributes.Add(new ObjectAttribute(CKA.CKA_CLASS, CKO.CKO_PRIVATE_KEY));
privateKeyAttributes.Add(new ObjectAttribute(CKA.CKA_KEY_TYPE, CKK.CKK_RSA));

List<ObjectHandle> foundPrivateKeys = session.FindAllObjects(privateKeyAttributes);
Console.WriteLine("Total private Key found : " + foundPrivateKeys.Count); // total = 2


Then to match current valid certificate... id add cka id for attribute


List<ObjectAttribute> privateKeyAttributes = new List<ObjectAttribute>();
privateKeyAttributes.Add(new ObjectAttribute(CKA.CKA_CLASS, CKO.CKO_PRIVATE_KEY));
privateKeyAttributes.Add(new ObjectAttribute(CKA.CKA_KEY_TYPE, CKK.CKK_RSA));
privateKeyAttributes.Add(new ObjectAttribute(CKA.CKA_ID, "11e333453512212")); // add this CKA_ID or CKA_LABEL

List<ObjectHandle> foundPrivateKeys = session.FindAllObjects(privateKeyAttributes);
Console.WriteLine("Total private Key found : " + foundPrivateKeys.Count); // total = 0


but when i count the private key , its get 0 ...already use cka or cka label.. but still dont get the private key match..

Please help if someone has experience this before .. Thank you


Reply all
Reply to author
Forward
0 new messages