c# – ASP.NET – 指定的网络密码不正确
发布时间:2020-12-15 17:49:27 所属栏目:百科 来源:网络整理
导读:我在我的开发机器上有一个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 即使网络之间没有密码,也没有证书密码. (我知道,因为开发工作没有密码). CrmServiceClient crm = new CrmServiceClient("CrmServiceEndpoint"); crm.ClientCredentials.UserName.UserName = CrmConfigRepository.CrmUserName;//fine crm.ClientCredentials.UserName.Password = CrmConfigRepository.CrmPassword;//fine crm.ClientCredentials.ClientCertificate.Certificate = new X509Certificate2(Path); ///THIS WONT WORK AS WELL crm.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:UsersaviDocumentsVisual Studio 2010ProjectsExpressBrokerExternalsCrmConnection.cs:31 ExpressBroker.Models.ActionsMetadata.Handlers.LeadAccountHandler.Handle(BrokerAction brokerAction,ActionStep step,Dictionary`2 httpPostDataCollection) in C:UsersaviDocumentsVisual Studio 2010ProjectsExpressBrokerExpressBrokerModelsActionsMetadataHandlersLeadAccountHandler.cs:45 ExpressBroker.Models.ActionsMetadata.Handlers.BaseStepHandler.SecuredHandle(BrokerAction brokerAction,Dictionary`2 httpPostDataCollection) in C:UsersaviDocumentsVisual Studio 2010ProjectsExpressBrokerExpressBrokerModelsActionsMetadataHandlersBaseStepHandler.cs:49 ExpressBroker.Models.ActionsMetadata.Handlers.HandlerInvoker.Invoke(BrokerAction brokerAction,ActionStep actionStep,Dictionary`2 stepValues) in C:UsersaviDocumentsVisual Studio 2010ProjectsExpressBrokerExpressBrokerModelsActionsMetadataHandlersStepServerInoker.cs:29 ExpressBroker.Controllers.LeadAccountController.Register(String step) in C:UsersaviDocumentsVisual Studio 2010ProjectsExpressBrokerExpressBrokerControllersLeadAccountController.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告诉构造函数查看始终存在的本地计算机密钥库. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- ruby-on-rails-3 – 如何在Rails 3.2中拯救来自中
- Swift requestWhenInUseAuthorization无效
- ruby – initialize和self.new之间的区别
- postgresql – 从查询更新Redshift表
- winforms – 如何确定要包含的“Oracle.DataAcce
- c# – NHibernate – NHibernate.Exceptions.Gen
- 【Python笔记】如何编译不依赖lapack和atlas库的
- Flex 启动失败 Failed to create the Java Virtu
- C#生成Word文档代码示例
- extjs4 常见问题解决
热点阅读