У меня следующий код для теста softhsm2 через библиотеку pkcs11interop
using Net.Pkcs11Interop.Common;
using Net.Pkcs11Interop.HighLevelAPI;
using Net.Pkcs11Interop.HighLevelAPI80;
using System;
using System.Collections.Generic;
namespace ExportTest
{
public class Softhsmtest
{
public static Pkcs11InteropFactories Factories = new Pkcs11InteropFactories();
public static void Test()
{
using (Pkcs11 pkcs11 = new Pkcs11(Factories, @"C:\SoftHSM2\lib\softhsm2.dll",AppType.MultiThreaded))
{
ISlot slot = pkcs11.GetSlotList(SlotsType.WithTokenPresent)[0];
using (ISession session = slot.OpenSession(SessionType.ReadWrite))
{
session.Login(CKU.CKU_USER, "1111");
session.Logout();
}
}
}
}
}
Ошибка Stacktrace, которую я получаю -
at System.Convert.ToUInt32(UInt64 value)
at Net.Pkcs11Interop.Common.ConvertUtils.UInt64ToCKR(UInt64 value)
at Net.Pkcs11Interop.LowLevelAPI80.Delegates.InitializeWithGetFunctionList(IntPtr libraryHandle)
at Net.Pkcs11Interop.LowLevelAPI80.Delegates..ctor(IntPtr libraryHandle, Boolean useGetFunctionList)
at Net.Pkcs11Interop.LowLevelAPI80.Pkcs11..ctor(String libraryPath)
at Net.Pkcs11Interop.HighLevelAPI80.Pkcs11..ctor(Pkcs11InteropFactories factories, String libraryPath, AppType appType)
at ExportTest.Softhsmtest.Test() in C:\Users\kashahid\Downloads
\ Pkcs11Interop-master \ Pkcs11Interop-master \ src \ PkcsTestWindowsApp \ Class1.cs: строка 15
в PkcsTestWindowsApp.Form1.button1_Click (Отправитель объекта, EventArgs e) в C: \ Users \ kashahid \ Downloads \ Pkcs11Interop-master \ Pkcs11Interop-master \ src \ PkcsTestWindowsApp \ Form1.cs: строка 27
в System.Windows.Forms.Control.OnClick (EventArgs e)
в System.Windows.Forms.Button.OnClick (EventArgs e)
в System.Windows.Forms.Button.OnMouseUp (MouseEventArgs mevent)
в System.Windows.Forms.Control.WmMouseUp (сообщение & m, кнопка MouseButtons, щелчки Int32)
в System.Windows.Forms.Control.WndProc (сообщение & m)
в System.Windows.Forms.ButtonBase.WndProc (сообщение & m)
в System.Windows.Forms.Button.WndProc (сообщение & m)
в System.Windows.Forms.Control.ControlNativeWindow.OnMessage (Message & m)
в System.Windows.Forms.Control.ControlNativeWindow.WndProc (Message & m)
в System.Windows.Forms.NativeWindow.DebuggableCallback (IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
в System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW (MSG & msg)
в System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop (IntPtr dwComponentID, причина Int32, Int32 pvLoopData)
в System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner (причина Int32, контекст ApplicationContext)
в System.Windows.Forms.Application.ThreadContext.RunMessageLoop (причина Int32, контекст ApplicationContext)
в System.Windows.Forms.Application.Run (Форма mainForm)
в PkcsTestWindowsApp.Program.Main () в C: \ Users \ kashahid \ Downloads \ Pkcs11Interop-master \ Pkcs11Interop-master \ src \ PkcsTestWindowsApp \ Program.cs: строка 19
https://github.com/Pkcs11Interop/Pkcs11Interop