我已经花了几个小时来解决这个错误。奇怪的是当我使用 this独立的库,它工作得非常好,但是当我将它们与我的 ASP .NET MVC 网站集成时,它开始抛出以下异常。我还根据建议使用了 MachineKeySet 标志 here但仍然没有运气。谁能帮我摆脱这个异常(exception)。谢谢。
An internal error occurred.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Security.Cryptography.CryptographicException: An internal error occurred.
Source Error:
Line 194: if (string.IsNullOrEmpty(p12FilePassword)) Line 196: certificate = new X509Certificate2(p12FileBytes, "", X509KeyStorageFlags.MachineKeySet); Line 197: else
最佳答案
我找到了解决方案 here .看起来像一个已知问题。我使用 X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable
标记在一起,问题就消失了。其他解决方案是将 applicationpool 的标识更改为 LOCALSERVICE。
关于exception - ASP.NET MVC : “An internal error occurred.” when loading certificate bytes with X509Certificate2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6097380/