您的位置: 首页 - Debugger scripts
  • 本站大部分内容从网上收集,收集目的仅供研究、学习。涉及版权或不希望收录您的文章请您及时与我联系。
  • 本站IM群,请自行选择。请各位朋友按照自己喜好加入。加入群后请及时发言,防止被清理。谢谢您的合作!!!
  • QQ群:Y①WEB开发(ASP.NET)号码:7351660 QQ群:Y②WEB开发(ASP+.NET)号码:11864905
  • QQ群:Y③WEB开发(DIV+CSS)号码:16610506 QQ群:Y④WEB开发(JS+AJAX)号码:16143998
  • QQ群:Y⑤WEB开发(新手)号码:12777715 MSN群:yaosansi[at]126.com

RSACryptoServiceProvider fails when used with ASP.NET

分类: C#|DOTNET 发布: yaosansi 浏览: 日期: 2010年7月20日

I will talk today about a very common issue we face when we try to use .NET's RSACryptoServiceProvider class in ASP.NET.When we try to create a new RSACryptoServiceProvider object in this scenario, we may get the following exception: "System.Security.Cryptography.CryptographicException: The system cannot find the file specified".By using my CryptoAPI Tracer script we can take a look to the CryptoAPI calls that .NET is making behind the scenes. Thanks to this script we will be able to see the exact API that is failing and the exact error (which most of the time .NET masks).In our case, the API that fails is CryptAcquireContext, and it fails with error #2 (ERROR_FILE_NOT_FOUND). According to CryptAcquireContext documentation, this error means the following:"The profile of the user is not loaded and cannot be found. This happens when the application impersonates a user, for example, the IUSR_ComputerName account."By default, ASP.NET won't load the user profile. Take a look to the parameters of the problematic CryptAcquireContext call as being shown in the log file that my script generated. If this API is not being called with CRYPT_MACHINE_KEYSET (to use the machine profile) or CRYPT_VERIFYCONTEXT (to use temporary key stores), it will try to access the key stores in the user profile, and it will fail because its not loaded.
分页:[«]1[»]

Powered By Z-Blog 1.8 Walle Build 100427

UNISON UPDATE Copyright 2005-2010 yaosansi'site All Rights Reserved.
感谢系统大玩家为本站提供FTP空间
辽ICP备05021434号