Error Importing Key The Specified Network Password
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might the specified network password is not correct. pfx have Meta Discuss the workings and policies of this site About
System.security.cryptography.cryptographicexception: The Specified Network Password Is Not Correct.
Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads the specified network password is not correct p12 with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million iis import certificate the specified network password is not correct programmers, just like you, helping each other. Join them; it only takes a minute: Sign up X509Certificate.CreateFromCertFile - the specified network password is not correct up vote 11 down vote favorite 4 I have a .NET application that I want to use as a client to call an SSL SOAP web service. I have been supplied
The Specified Network Password Is Not Correct Iis
with a valid client certificate called foo.pfx. There is a password on the certificate itself. I've located the certificate at the following location: C:\certs\foo.pfx To call the web service, I need to attach the client certificate. Here's the code: public X509Certificate GetCertificateFromDisk(){ try{ string certPath = ConfigurationManager.AppSettings["MyCertPath"].ToString(); //this evaluates to "c:\\certs\\foo.pfx". So far so good. X509Certificate myCert = X509Certificate.CreateFromCertFile(certPath); // exception is raised here! "The specified network password is not correct" return cert; } catch (Exception ex){ throw; } } It sounds like the exception is around the .NET application trying to read the disk. The method CreateFromCertFile is a static method that should create a new instance of X509Certificate. The method isn't overridden, and has only one argument: the path. When I inspect the Exception, I find this: _COMPlusExceptionCode = -532459699 Source=mscorlib Question: does anyone know what the cause of the exception "The specified network password is not correct" ? c# ssl-certificate x509certificate share|improve this question asked May 22 '09 at 21:04 p.campbe
here for a quick overview of the site Help Center Detailed answers to any pushsharp the specified network password is not correct questions you might have Meta Discuss the workings and policies of x509certificate.createfromcertfile password this site About Us Learn more about Stack Overflow the company Business Learn more about
New X509certificate2 The Specified Network Password Is Not Correct
hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow http://stackoverflow.com/questions/899991/x509certificate-createfromcertfile-the-specified-network-password-is-not-corre is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up ASP.NET - The specified network password is not correct up vote 7 down vote favorite 4 I have in my dev machine a WCF Client which requires certificate and it is http://stackoverflow.com/questions/8286110/asp-net-the-specified-network-password-is-not-correct working fine. After the deployment to production server I get the following Error: [CryptographicException: The specified network password is not correct.] DEV - Win7 32BIT IIS 7.5 PRODUCTION - Win SERVER 64BIT 2008 IIS 7.5 Even though there is no password between the networks and there is not certificate password. (I know because the dev works with no password). The only password that I have is the WCF one that is the same as the DEV. 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); this is the full stack [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\
"specified network password is not correct" This has happened to me twice in the last six months, and I keep forgetting the incredibly simple fix, so I'm posting it here, both for my own https://cushen.wordpress.com/2010/02/10/fixing-strong-name-password-errors/ use, and in the hope that I can help someone else. Here's the scenario: http://vdachev.net/2012/03/07/c-sharp-error-creating-x509certificate2-from-a-pfx-or-p12-file-in-production/ you are merrily programming away in Visual Studio 2005 or 2008, with a project open which you have signed with a Strong Name, which in turn you have protected with a password. Then, boom! Either Visual Studio , or Windows itself, crashes; or, maybe one of those @#$%& Windows Updates re-starts your PC when your back the specified is turned.Fingers crossed, you boot up, open Visual Studio, and there it is- you are greeted with a message offering to recover a file that was open at the moment of "disaster". Of course, you choose Yes; and then either Visual Studio, or you, open the Project that was open. Everything looks fine, until you try to build/debug; then you get a message asking for the password to your Strong the specified network Name key file, so the key can be "imported". This seems curious, since the key should already be there; you even see the file if you look at Project Explorer on the right side of the Visual Studio window. But, whatever; you enter your password. And that's when this issue rears up and smacks you in the face. Your password is rejected; "network password?? this is a key file, not a network resource!" "Hmm…that's strange…I'm pretty sure that's the correct password…oh well, let me try again." So you try again…and get either an "incorrect password" message, or a really strange one: "specified network password is not correct". "But I'm not trying to access anything on the network!! What gives??" At this point, I thought I recalled fixing this by un-checking the "Sign the assembly" checkbox in the Project properties, building the project, then signing it again; but that didn't work this time. Update from the source code repository? That was my next thought; it didn't work. I didn't go as far as checking out a new working copy into a new directory, so I don't know if that would have worked; but, as it turns out, that would have been overkill. There's a much simpler solution. Read on…
ExtractorWordPressКонтактGoogle Search Valery's Mlog Mindlog of a Freak March 7th, 2012 by Valery Dachev C#: Error Creating X509Certificate2 from a PFX or P12 File in Production Problem Today I stumbled upon a problem instantiating a X509Certificate2 class from a PKCS#12 container (a .pfx or a .p12 file) in production environment. For some reason I kept getting "The specified network password is not correct." (for password-less containers) or "An internal error occurred." (for protected ones). Cause The cause of the problem doesn't seem to have much to do with the error messages.For some reason the constructor is trying to get access to the private key store although the private key is in stored in the file being opened. By default the user key store is used but ASP.NET (and probably non-interactive Windows services in general) are not allowed to open it. Chances are the user key store for the selected account doesn't even exist. Solution One thing you could try is creating a user key store by logging into the account and importing a certificate in its Personal store (and then remove it again). Another solution is to pass an additional parameter to the constructor - a flagindicating the private keys are (supposed to be) stored in the local computer - X509KeyStorageFlags.MachineKeySet, like this: var certificate = new X509Certificate2(fileName, password, X509KeyStorageFlags.MachineKeySet); Click to share on Pinterest (Opens in new window)Click to share on Facebook (Opens in new window)Click to share on Pocket (Opens in new window)Click to share on Twitter (Opens in new window)Click to share on Google+ (Opens in new window)Click to share on LinkedIn (Opens in new window)Click to share on Tumblr (Opens in new window)Click to share on Reddit (Opens in new window)Click to email this to a friend (Opens in new window)Click to print (Opens in new window)Like this:Like Loading... Related Tags: .NET Framework, C#, p12, PFX, PKCS#12, X509Certficiate2, X509KeyStorageFlags Posted in Articles Comments 6 Responses to "C#: Error Creating X509Certificate2 from a PFX or P12 File in Production" Jun 01 2012 at 04:58 kevin says thanks a lot, it work well now Jun 12 2012 at 04:46 Paul says Thanks, I found this post very useful. Sep 19 2012 at 01:30 Alia says Thanks!! :) Aug 30 2013 at 13:55 manish sharma says thanks it helped :) Oct 22 2013 at 11:49 kentaro says it is very helpful, thanks! Nov 10 2015 at 02:54 Creating X509Certificate2 certificate causes