我在高亮行中得到了访问冲突异常。
试图读取或写入受保护的内存。这通常表明其他内存已损坏。
我有hsm和label的证书。我正在将我的应用程序构建为x64
public void getCertificateFromHSM(string certLabel) {
List<ObjectAttribute> objectAttributes = new List<ObjectAttribute>();
objectAttributes.Add(new ObjectAttribute(CKA.CKA_CLASS, CKO.CKO_CERTIFICATE));
objectAttributes.Add(new ObjectAttribute(CKA.CKA_LABEL, certLabel));
**session.FindObjectsInit(objectAttributes);** --Exception from here
// Get search results
List<ObjectHandle> foundObjects = session.FindObjects(2);
// Terminate searching
session.FindObjectsFinal();
// Prepare list of empty attributes we want to read
List<CKA> attributes = new List<CKA>();
attributes.Add(CKA.CKA_LABEL);
attributes.Add(CKA.CKA_VALUE);
} 我从这一行中得到了异常,session.FindObjectsInit();。我是pkcs11的新手。
在这方面的任何帮助都将受到赞赏。
我还试图通过传递32位crypto.dll将应用程序构建为32位,但在这种情况下,我从PKCS11Interop Net.Pkcs11Interop.LowLevelAPI81.Delegates.InitializeWithGetFunctionList(IntPtr libraryHandle)中的这一行获得异常,异常是
对于UInt32来说,值要么太大要么太小。OverflowExcepiton未被处理。
发布于 2017-04-12 06:35:14
您似乎使用了错误的HighLevelAPI集。您需要使用Net.Pkcs11Interop.HighLevelAPI命名空间中的类,最后不要使用任何数字。
换句话说,您需要使用以下行
using Net.Pkcs11Interop.HighLevelAPI;在您的代码中而不是
using Net.Pkcs11Interop.HighLevelAPI81;有关更多信息,请参见Pkcs11Interop库体系结构,您也可以查看官方代码样本,它也在使用Net.Pkcs11Interop.HighLevelAPI。
https://stackoverflow.com/questions/43358353
复制相似问题