exception - ASP.NET MVC : “An internal error occurred.” when loading certificate bytes with X509Certificate2

标签 exception asp.net-mvc-3 x509certificate2

我已经花了几个小时来解决这个错误。奇怪的是当我使用 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/

相关文章:

javascript - 将函数回调绑定(bind)到kendo网格上

c# - 在 Linux Docker 容器中运行时无法读取证书 - 适用于 Windows

使用没有私钥的 X.509 证书的 C# 解密

java - 异常处理,catch导致while循环停止

python - 如何使用 flask + Gevent-socketio 制作 werkzeug/自定义错误页面

jquery - ASP.NET MVC 3 Razor 显示对话框

c# - 为什么在 View 中检查 null 时会出现 NullReferenceException

azure - 使用azure管理库时有没有办法缩小授权范围?

python - 依赖异常是一种不好的形式吗?

java - 返回异常是反模式吗?