0

I have an application to sign a PDF file and I need to extract from token certificate and private key to do this.

I need a code in C# with Pkcs11Interop LowLevel API. I've tried with this code:

bool success = true; 
CK_ATTRIBUTE[] template = new CK_ATTRIBUTE[2]; 
template[0] = CkaUtils.CreateAttribute(CKA.CKA_CLASS, CKO.CKO_CERTIFICATE); 
template[1] = CkaUtils.CreateAttribute(CKA.CKA_TOKEN, true);
List<IObjectHandle> foundObjects = new List<IObjectHandle>();
CKR test = pkcs11.C_FindObjectsInit(SessionOpened, template, Convert.ToUInt32(template.Length)); 
aaossa
  • 3,763
  • 2
  • 21
  • 34
  • Please provide enough code so others can better understand or reproduce the problem. – Community Feb 23 '22 at 04:36
  • bool success = true; CK_ATTRIBUTE[] template = new CK_ATTRIBUTE[2]; template[0] = CkaUtils.CreateAttribute(CKA.CKA_CLASS, CKO.CKO_CERTIFICATE); template[1] = CkaUtils.CreateAttribute(CKA.CKA_TOKEN, true); List foundObjects = new List(); CKR test = pkcs11.C_FindObjectsInit(SessionOpened, template, Convert.ToUInt32(template.Length)); – gociu bogdan Feb 23 '22 at 08:21
  • if you want to use smartcard/token in the web application, check answer https://stackoverflow.com/a/63173083/9659885 – Bharat Vasant Apr 21 '22 at 06:44

0 Answers0