none
X509 ;System.Security.Cryptography.CryptographicException : The specified network password is not correct RRS feed

  • Question

  • I get this error on 2003 r2 server when loading X509 certificate from *.pfx file . It works on 2008 server and windows 7

     System.Security.Cryptography.CryptographicException : The specified network password is not correct. 
     at System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr)
    at System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromFile(String fileName, IntPtr password, UInt32 dwFlags, Boolean persistKeySet, SafeCertContextHandle& pCertCtx)
    at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromFile(String fileName, Object password, X509KeyStorageFlags keyStorageFlags)
    at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(String fileName)
    at System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(String fileName)

    Wednesday, February 23, 2011 6:56 PM

Answers

  • X509Certificate2 has 2nd constructor which takes password. This is required for windows 2003 and below.Also password should not be more then 32 characters

    • Marked as answer by chintapali Thursday, March 10, 2011 2:06 AM
    Thursday, March 10, 2011 2:06 AM

All replies

  •  

    Hi,

     

    What .NET Framework version you’re using? .NET 2.0 or .NET 4.0? we're doing research on this case, it will be helpful if you can provide more information helping us to repro this issue.


    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, February 24, 2011 6:47 AM
  • Assembly is running under .NET Framework :  .NET Framerwork 3.5

    But there is .NET 4.0 installed on the machine

    OS: windows server 2003 R2 sp2

     

     

    Thursday, February 24, 2011 1:31 PM
  • Is there an update on this?

    Monday, February 28, 2011 5:39 PM
  • The issue here is with the application that fails to load a certificate from a PFX file. Gaining an exception on Windows Server 2003 and the exception is "System.Security.Cryptography.CryptographicException: The specified network password is not correct." 

     

    You need to check for the PFX password length when creating the PFX. On Windows XP or Windows Server 2003, any characters greater or equal to 32 characters are ignored. Windows Server 2008 has no password limit so the code succeeds on that OS. On Windows Server 2003 the code fails to load the PFX because the password is more than 31 characters in length. You might have to shorten the password to make it compatible on Windows Server 2003.


    bill boyce
    Tuesday, March 1, 2011 2:52 PM
    Moderator
  • I guess that is not the reason. My password is 10 characters long .

    Tuesday, March 1, 2011 4:43 PM
  • Hi,

    I did some searches and these two links were the closest I found so far to your error.

    Please review and let me know if this helps out.

    http://code.google.com/p/apns-sharp/issues/detail?id=36

     

    receive a "System.Security.Cryptography.CryptographicException: The specified network password is not correct." exception when attempting use a passwordless key on Windows Server 2003 (XP may also be affected) Vista, Windows 7 and windows Server 2008 are not affected.

    http://www.codeproject.com/KB/WCF/wcfcertificates.aspx?msg=3248769

     


    bill boyce
    Tuesday, March 1, 2011 7:40 PM
    Moderator
  • X509Certificate2 has 2nd constructor which takes password. This is required for windows 2003 and below.Also password should not be more then 32 characters

    • Marked as answer by chintapali Thursday, March 10, 2011 2:06 AM
    Thursday, March 10, 2011 2:06 AM
  • Hi Bill,

    Any news on this?

    I have a similar problem that only occurs on Server2003, on W7 and 2008R2 it works fine.

    These are the commands:

    makecert -pe -n "CN=bla" -sv bla.pvk bla.cer (here I click None to have no pvk password)
    pvk2pfx -f -pvk bla.pvk -spc bla.cer -pfx bla.pfx
    mage -sign "bla.manifest" -cf bla.pfx (fails on 2003 with incorrect network password)

    I can make it work by specifying a PFXpassword (but still without a PVK password) like this:

    makecert -pe -n "CN=bla" -sv bla.pvk bla.cer (here I click None to have no pvk password)
    pvk2pfx -f -pvk bla.pvk -spc bla.cer -pfx bla.pfx -po "pfxpassword"
    mage -sign "bla.manifest" -cf bla.pfx -pwd "pfxpassword"

    Why do I need a PFX password on 2003 and not on 7 or 2008?

    Kind regards,

    Michel.

     

     

    Friday, July 22, 2011 8:37 AM
  • Hi,

     I have same error..I also try for 2nd & 3rd argument but still not solve.

    My code is...

    X509Certificate2 RootCAPemLocalFilePath = new X509Certificate2(rootCAPemFullFilePathSpec, "", X509KeyStorageFlags.MachineKeySet);

    how can I solve this issue... plz... help me

     


    I use Window 7
    Monday, January 23, 2012 12:59 PM
  • I had a same problem on win 2003 r2. I solved this problem creating a file .pfx and .cer without password


    C:\>makecert -pe -n "CN=bla" -sv bla.pvk bla.cer
    Succeeded

    C:\>pvk2pfx -f -pvk bla.pvk -spc bla.cer -pfx bla.pfx

    Tuesday, August 5, 2014 8:40 PM