我正在尝试使用带有pkcs11interop的asmx Web服务获取HSM(ATOS HSM Trustway Proteccio™NetHSM)插槽信息。 我的Web服务正在Visual Studio中使用IIS 10 Express获取信息。当我尝试在Windows 10上将Web服务部署到IIS 10时出现此错误:
Net.Pkcs11Interop.Common.Pkcs11Exception:方法C_Initialize返回了CKR_CRYPTOKI_NOT_INITIALIZED àNet.Pkcs11Interop.HighLevelAPI41.Pkcs11..ctor(字符串libraryPath,AppType appType) àNet.Pkcs11Interop.HighLevelAPI.Pkcs11..ctor(字符串libraryPath,AppType appType) àTest.WebService1.TestHsm()dans C:\ Users \ jussieu \ Source \ Repos \ Test \ TestHsm.asmx.cs:ligne 30
pkcs11-logger的日志为: 调用C_Initialize 0x00003f7c:0x00003db0:输入 0x00003f7c:0x00003db0:pInitArgs:13FB979C 0x00003f7c:0x00003db0:CreateMutex:00000000 0x00003f7c:0x00003db0:销毁静音:00000000 0x00003f7c:0x00003db0:LockMutex:00000000 0x00003f7c:0x00003db0:解锁互斥:00000000 0x00003f7c:0x00003db0:标志:2 0x00003f7c:0x00003db0:CKF_LIBRARY_CANT_CREATE_OS_THREADS:FALSE 0x00003f7c:0x00003db0:CKF_OS_LOCKING_OK:是 0x00003f7c:0x00003db0:p保留:00000000 0x00003f7c:0x00003db0:返回400(CKR_CRYPTOKI_NOT_INITIALIZED)
由于一切对我来说都是新的,我迷路了,需要一些帮助(请) 谢谢
我正在使用
string retourE = "Hello";
if (Net.Pkcs11Interop.Common.Platform.Uses64BitRuntime)
{
pkcs11LibraryPath = @"C:\Windows\System32\nethsm.dll";
loggerLibrary = @"C:\Users\jussieu\PROJETS\HSM\lib\pkcs11-logger-x64.dll";
logFile = @"C:\Users\jussieu\Documents\PROJETS\HSM\lib\pkcs11-logger-x64.log";
}
else
{
pkcs11LibraryPath = @"C:\Windows\SysWOW64\nethsm.dll";
loggerLibrary = @"C:\Users\jussieu\Documents\PROJETS\HSM\lib\pkcs11-logger-x86.dll";
logFile = @"C:\Users\jussieu\Documents\PROJETS\HSM\lib\pkcs11-logger-x86.log";
}
System.Environment.SetEnvironmentVariable("PKCS11_LOGGER_LIBRARY_PATH", pkcs11LibraryPath);
System.Environment.SetEnvironmentVariable("PKCS11_LOGGER_LOG_FILE_PATH", logFile);
System.Environment.SetEnvironmentVariable("PKCS11_LOGGER_FLAGS", "64");
using (Pkcs11 pkcs11 = new Net.Pkcs11Interop.HighLevelAPI.Pkcs11(loggerLibrary, AppType.MultiThreaded))
{
// Show general information about loaded library
LibraryInfo libraryInfo = pkcs11.GetInfo();
Console.WriteLine("Library");
Console.WriteLine(" Manufacturer: " + libraryInfo.ManufacturerId);
Console.WriteLine(" Description: " + libraryInfo.LibraryDescription);
Console.WriteLine(" Version: " + libraryInfo.LibraryVersion);
// Get list of all available slots
foreach (Slot slot in pkcs11.GetSlotList(SlotsType.WithOrWithoutTokenPresent))
{
// Show basic information about slot
SlotInfo slotInfo = slot.GetSlotInfo();
Console.WriteLine();
Console.WriteLine("Slot ");
Console.WriteLine(" Manufacturer: " + slotInfo.ManufacturerId);
Console.WriteLine(" Description: " + slotInfo.SlotDescription);
Console.WriteLine(" Token present: " + slotInfo.SlotFlags.TokenPresent);
if (slotInfo.SlotFlags.TokenPresent)
{
// Show basic information about token present in the slot
TokenInfo tokenInfo1 = slot.GetTokenInfo();
Console.WriteLine("Token 1");
Console.WriteLine(" Manufacturer: " + tokenInfo1.ManufacturerId);
Console.WriteLine(" Model: " + tokenInfo1.Model);
Console.WriteLine(" Serial number: " + tokenInfo1.SerialNumber);
Console.WriteLine(" Label: " + tokenInfo1.Label);
retourE = tokenInfo1.Label.ToString();
// Show list of mechanisms supported by the token
Console.WriteLine("Supported mechanisms TOKENS 1: ");
foreach (CKM mechanism in slot.GetMechanismList())
Console.WriteLine(" " + mechanism);
}
}
return retourE;
}
我希望Web服务可以在IIS 10上运行,但只能在IIS EXPRESS上运行