我想X509Certificate2
从字符串创建.让我举个例子:
string keyBase64String = Convert.ToBase64String(file.PKCS7);
var cert = new X509Certificate2(Convert.FromBase64String(keyBase64String));
Run Code Online (Sandbox Code Playgroud)
并keyBase64String
有这样的内容:"MIIF0QYJKoZI ........hvcNAQcCoIIFwjCCBb4CA0="
并且file.PKCS7
是我从数据库下载的字节数组.
创建时我遇到以下异常X509Certificate2
:
找不到请求的对象
并且堆栈跟踪:
"无法在系统中的System.Security.Cryptography.X509Certificates.X509Utils._QueryCertBlobType(Byte [] rawData)处的System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32hr)中找不到请求的对象"X509Certificate2异常"无法找到请求的对象"}. WebApp.SoupController.d__7.MoveNext()上的System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte [] rawData)中的Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(Byte [] rawData,Object password,X509KeyStorageFlags keyStorageFlags)在D:\ Projects\WebApp\Controllers\SoupController.cs中:第118行
请告诉我我做错了什么.任何帮助将不胜感激!