开发者

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

I have already spent a few hours to resolve this error. The weird thing is when I use this libraries indepen开发者_开发问答dently, it works absolutely fine but when I integrate them with my ASP .NET MVC website, it start throwing the following exception. I have also used MachineKeySet flag based on suggestion here but still no luck. Could anyone please help me to get rid of this exception. Thanks.

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


I found the solution here. Looks like a known issue. I used X509KeyStorageFlags.MachineKeySet | X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.Exportable flags together and problem disappeared. Other solution is to change the identity of applicationpool to LOCALSERVICE.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜