Eon*_*Eon 5 c# cryptography certificate private-key
美好的一天
由于此错误,我在尝试分配私钥时遇到严重问题.
System.Security.Cryptography.CryptographicException: Keyset does not exist
var store = new X509Store(StoreName.My, StoreLocation.LocalMachine);
store.Open(OpenFlags.ReadOnly);
var col = store.Certificates.Find(X509FindType.FindBySerialNumber, "00873476DC47C5BB614EA96F2A9CE744A6", false);
var cert = col[0];
var xmlUnSignedSaml = new XmlDocument();
xmlUnSignedSaml.LoadXml(assertion);
xmlUnSignedSaml.PreserveWhitespace = true;
SignedXml signedXml = new SignedXml(xmlUnSignedSaml);
signedXml.SigningKey = cert.PrivateKey; //<<<--- Exception thrown.
Run Code Online (Sandbox Code Playgroud)
我已经验证了以下内容:
我已经在以下几页检查了答案,但绝对没有一个对我有效:
我从Visual Studio中运行应用程序,并在上面的代码段,它会抛出异常尝试设置 SignedXml's SigningKey
我还能做些什么才能让它运行起来?(事后补充,我也尝试过对cert和文件夹的"Everyone"权限 - 即使抛出相同的异常)
我已经使用以下步骤解决了我的问题:
ctrl+shift+B。Main(string args[])因为我很懒,不想通过控制台来执行此操作:args = new string[] { "My", "LocalMachine", "-t", THUMBPRINT_OBTAINED_IN_MMC, "-a" };我更改了密钥本身的权限,我的应用程序开始运行。
| 归档时间: |
|
| 查看次数: |
5053 次 |
| 最近记录: |