2011-11-27 22 views
11

Dev makinemde sertifika gerektiren bir WCF İstemcisine sahibim ve gayet iyi çalışıyor. üretim sunucusuna dağıtım sonra
aşağıdaki hata alıyorum:ASP.NET - Belirtilen ağ şifresi doğru değil

[CryptographicException: The specified network password is not correct.] 

DEV - hayır yoktur rağmen kazanın SUNUCU 64BIT 2008 7.5

IIS - Win7 32BIT 7.5
ÜRETİM IIS Ağlar arasında şifre var ve sertifika şifresi yok. (Biliyorum çünkü dev şifre olmadan çalışır). Sahip olduğum tek şifre, DEV ile aynı olan WCF'dir.

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); 

bu tam yığınına

[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, ActionStep step, 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, ActionDescriptor actionDescriptor, 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 

Teşekkür

+0

X509Certificates kurgusunda geçen yol nedir? Sertifika dosyasına erişen ağ şifresi olduğunu düşünüyorum. – Simon

+0

Olası kopya mı? http://stackoverflow.com/q/899991/130352 –

cevap

32

bu deneyin:

new X509Certificate2(Path, "", X509KeyStorageFlags.MachineKeySet); 

O X509Certificate2 yapıcı yerel özel anahtar deposunu erişmeye çalıştığında görünür kullanıcı (bir PFX'i yüklerken ve özel anahtar PFX'te olsa bile). Asp.net ile, kullanıcı profili genellikle yüklenmez, bu nedenle kullanıcı anahtarı deposu mevcut değildir. MachineKeySet öğesinin belirlenmesi, kurucunun her zaman var olan Yerel Bilgisayar anahtar deposuna bakmasını söyler.

+3

Günümü kurtardım ... crypto API'sını yaptığında ne düşündüğünü. Yanıyor olduğum certs'lerde bu sadece bir tuhaflık değil. –

+0

Teşekkürler! Bu kadar kötü bir sınıfı kullanmayı hiç düşünmedim, ama sadece bu çalışma çözümü! – balint

+0

Bunun için teşekkürler! – TheWebGuy

İlgili konular