c# – ASP.NET – 指定的网络密码不正确

c# – ASP.NET – 指定的网络密码不正确,第1张

概述我在我的开发机器上有一个WCF客户端,需要证书,它工作正常. 部署到生产服务器后,我得到以下错误: [CryptographicException: The specified network password is not correct.] DEV – Win7 32BIT IIS 7.5 生产 – Win SERVER 64BIT 2008 IIS 7.5 即使网络之间没有密码,也没有证书密 我在我的开发机器上有一个WCF客户端,需要证书,它工作正常.
部署到生产服务器后,我得到以下错误:
[CryptographicException: The specifIEd network password is not correct.]

DEV – Win7 32BIT IIS 7.5
生产 – Win SERVER 64BIT 2008 IIS 7.5

即使网络之间没有密码,也没有证书密码. (我知道,因为开发工作没有密码).
我唯一的密码是与DEV相同的WCF.

CrmServiceClIEnt crm = new CrmServiceClIEnt("CrmServiceEndpoint");crm.ClIEntCredentials.Username.Username = CrmConfigRepository.CrmUsername;//finecrm.ClIEntCredentials.Username.Password = CrmConfigRepository.CrmPassword;//finecrm.ClIEntCredentials.ClIEntCertificate.Certificate = new X509Certificate2(Path);///THIS WONT WORK AS WELLcrm.ClIEntCredentials.ClIEntCertificate.Certificate = new X509Certificate2(Path,"",X509KeyStorageFlags.Exportable);

这是完整的堆栈

[CryptographicException: The specifIEd network password is not correct. ]   System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr) +41   System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromfile(String filename,IntPtr password,UInt32 DWFlags,Boolean persistKeySet,SafeCertContextHandle& pCertCtx) +0   System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromfile(String filename,Object password,X509KeyStorageFlags keyStorageFlags) +372   System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String filename) +101   Externals.CrmConnection.Get() in C:\Users\avi\documents\Visual Studio 2010\Projects\Expressbroker\Externals\CrmConnection.cs:31   Expressbroker.Models.ActionsMetadata.Handlers.LeadAccountHandler.Handle(brokerAction brokerAction,ActionStep step,Dictionary`2 httpPostDataCollection) in C:\Users\avi\documents\Visual Studio 2010\Projects\Expressbroker\Expressbroker\Models\ActionsMetadata\Handlers\LeadAccountHandler.cs:45   Expressbroker.Models.ActionsMetadata.Handlers.BaseStepHandler.SecuredHandle(brokerAction brokerAction,Dictionary`2 httpPostDataCollection) in C:\Users\avi\documents\Visual Studio 2010\Projects\Expressbroker\Expressbroker\Models\ActionsMetadata\Handlers\BaseStepHandler.cs:49   Expressbroker.Models.ActionsMetadata.Handlers.HandlerInvoker.Invoke(brokerAction brokerAction,ActionStep actionStep,Dictionary`2 stepValues) in C:\Users\avi\documents\Visual Studio 2010\Projects\Expressbroker\Expressbroker\Models\ActionsMetadata\Handlers\StepServerInoker.cs:29   Expressbroker.Controllers.LeadAccountController.Register(String step) in C:\Users\avi\documents\Visual Studio 2010\Projects\Expressbroker\Expressbroker\Controllers\LeadAccountController.cs:28   lambda_method(Closure,ControllerBase,Object[] ) +127   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext,IDictionary`2 parameters) +264   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext,ActionDescriptor actionDescriptor,IDictionary`2 parameters) +39   System.Web.Mvc.<>c__displayClass15.<InvokeActionMethoDWithFilters>b__12() +129   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter,ActionExecutingContext preContext,Func`1 continuation) +784922   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethoDWithFilters(ControllerContext controllerContext,IList`1 filters,IDictionary`2 parameters) +314   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext,String actionname) +784976   System.Web.Mvc.Controller.ExecuteCore() +159   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335   System.Web.Mvc.<>c__displayClassb.<BeginProcessRequest>b__5() +62   System.Web.Mvc.Async.<>c__displayClass1.<MakeVoIDDelegate>b__0() +20   System.Web.Mvc.<>c__displayClasse.<EndProcessRequest>b__d() +54   System.Web.CallHandlerExecutionStep.System.Web.httpApplication.IExecutionStep.Execute() +453   System.Web.httpApplication.ExecuteStep(IExecutionStep step,Boolean& completedSynchronously) +371

谢谢

解决方法 尝试这个:
new X509Certificate2(Path,X509KeyStorageFlags.MachineKeySet);

看来,X509Certificate2构造函数尝试访问本地用户的私钥存储(即使加载PFX,私钥在PFX中).使用asp.net,用户配置文件通常没有加载,所以用户密钥库不存在.指定MachineKeySet告诉构造函数查看始终存在的本地计算机密钥库.

总结

以上是内存溢出为你收集整理的c# – ASP.NET – 指定的网络密码不正确全部内容,希望文章能够帮你解决c# – ASP.NET – 指定的网络密码不正确所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1237394.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-06
下一篇 2022-06-06

发表评论

登录后才能评论

评论列表(0条)

保存