ASP.NET - The specified network password is not correct - X509Certificate2

Nabeel Farooq 0 Reputation points
2024-04-30T12:08:12.77+00:00

I have a .NET web application where trying to import the certificate using the "X509Certificate2".

While importing, getting the "The specified network password is not correct.". The certificate is password protected .pfx file and I'm providing the password too while importing the certificate. Here are the steps to produce the issue:

In Global.asax.cs file, loading/importing the certificate on Application_Start by using:

X509Certificate2

It's breaking and throwing the exception "The specified network password is not correct".

saml

I tried multiple solutions like:

  • Setting user profile true in IIS
  • Setting up multiple key flags like (DefaultKeySet, MachineKeySet, UserKeySet, etc)

But nothing works.

Any help would be appreciated.

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,303 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Lan Huang-MSFT 26,121 Reputation points Microsoft Vendor
    2024-05-01T03:35:11.9833333+00:00

    Hi @Nabeel Farooq,

    There are many reasons that may cause this error message.

    You can troubleshoot based on the following points:

    • Check PFX file.

    Problem was, it was exported using AES256-SHA256 encryption, which threw the same exception as in the question. According to this, AES256-SHA256 is only supported on Windows 10 1703, Windows Server 2016 and above. Changing to TripleDES-SHA1 'solved' the issue.

    • The 'the specified network password is not correct' error message is also returned when the certificate you are trying to import in one of the OS stores is already present in that store.
    • Try changing the Identity in the application pool to NetworkService.
    • Check password length:0 < password.Length < 32

    Links that may be helpful:

    https://learn.microsoft.com/en-us/answers/questions/1308437/issue-the-specified-network-password-is-not-correc

    ASP.NET - The specified network password is not correct

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments