I am trying to do Digital Signing of XML via HSM using C#.NET language.
I am able to do the same via PKCS11Interop DLL.
But if I am trying to sign multiple threads then I am unable to access the library and it crashes.
Please find below Error and Code used
Error is : Method C_Initialize returned CKR_FUNCTION_FAILED at Net.Pkcs11Interop.HighLevelAPI4.Pkcs11..ctor(String libraryPath, Boolean useOsLocking) at Net.Pkcs11Interop.HighLevelAPI.Pkcs11..ctor(String libraryPath, Boolean useOsLocking)
public Slot GetUsableSlot(Pkcs11 pkcs11)
{
// Get list of available slots
List<Slot> slots = pkcs11.GetSlotList(true);
// Let's use first slot with token present
return slots[1];
}
public void SignTest()
{
using (Pkcs11 pkcs11 = new Pkcs11(Pkcs11LibraryPath, true))
{
Slot slot = GetUsableSlot(pkcs11);
// Open RW session
using (Session session = slot.OpenSession(false))
{
// Login as normal user
session.Login(CKU.CKU_USER, "xxxx");
...........................
...........................
--
You received this message because you are subscribed to the Google Groups "Pkcs11Interop" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pkcs11intero...@googlegroups.com.
To post to this group, send email to pkcs11...@googlegroups.com.
Visit this group at http://groups.google.com/group/pkcs11interop.
Thanks a lot Jaroslav for your revert.
I have tried the combinations mentioned in the thread suggested.
Also tried some Trail and error of my own.
But still multi-threading is not working.
Combinations I have tried:
1. Global declaration of the PKCS11 object with native OS locking model enabled
2. Create new session object for every thread
3. Single session object and login for every thread.
I am still unable to access the PKCS11 library and it crashes.
I am trying to access keys stored in Thales HSM....