部署時,出現用戶代碼未處理 System.Security.Cryptography.CryptographicException 錯誤解決方法


在調用RSA加密的.pfx密鑰時,在本地調試沒有問題,可以布署到服務器,就會報以下的錯誤:

用戶代碼未處理 System.Security.Cryptography.CryptographicException
  HResult=-2146893792
  Message=出現了內部錯誤。

  Source=mscorlib
  StackTrace:
       在 System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
       在 System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromFile(String fileName, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx)
       在 System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags)
       在 System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName, String password, X509KeyStorageFlags keyStorageFlags)
       在 xxxxx.API.Tools.RSA.Sign(String data, String keyPath, String keyPasswd)
       在 xxxxx.API.Tools.Encrypt.signANDencrypt(MsgBean req_bean)
       在 xxxxx.API.xxxxx.GetBankCardInfo(String orderId, String cardNo)
       在 xxxxx.GetBankCardInfo(GetBankCardInfoReq request) 位置 d:\app_service\WHTR_SOA\WHTR.SOA.Services\OnlinePay\Yilian\OnlinePayService.cs:行號 108
       在 Castle.Proxies.Invocations.xxxxx.InvokeMethodOnTarget()
       在 Castle.DynamicProxy.AbstractInvocation.Proceed()
       在 xxxxx.CastleMethodInvocation.Proceed() 位置 d:\xxxxx.cs:行號 80
       在 xxxxx.Intercept(IMethodInvocation invocation) 位置 d:\xxxxx.cs:行號 56
  InnerException: 

處理方法:

IIS 應用程序池--選中你網站的所配置的應用程序池--右鍵 選擇 “高級配置” --將“加載用戶配置文件” 設置為True 。問題解決

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM