【发布时间】:2014-04-02 14:49:33
【问题描述】:
在尝试使用我生成的 SNK 文件并在 Visual Studio 2013 中使用它来签署我的程序集时,我不断收到此错误:
CSC:错误 CS1548:签署程序集时出现加密错误 'd:\temp\MyDell.dll' -- '错误签名程序集 -- 未知错误 (8013141e)'
我已将 signtool 与我的 PFX 和密码一起使用,一切正常,它对程序集进行签名。所以 PFX 似乎不错。
我正在使用这个代码,我以前用它来生成我的 SNK,它一直有效:
X509Certificate2 cert = new X509Certificate2(@"c:\temp\FILENAME.pfx", "PASSWORD", X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet);
RSACryptoServiceProvider provider = (RSACryptoServiceProvider) cert.PrivateKey;
byte[] array = provider.ExportCspBlob(!provider.PublicOnly);
using (FileStream fs = new FileStream(@"c:\temp\FILENAME.snk", FileMode.Create, FileAccess.Write))
{
fs.Write(array, 0, array.Length);
}
有人知道我为什么会收到这个错误吗?有没有更好的方法来生成 SNK 文件?
谢谢
【问题讨论】:
-
这不是一个完全未知的错误,0x8013141e 是 CORSEC_E_INVALID_PUBLICKEY。
标签: c#