PFX import on Windows: “The password you entered is incorrect”

The PFX file comes fresh from a Linux server or a new Windows machine, the password is definitely right, and still Windows Server 2016 says “The password you entered is incorrect”. The culprit is not the password but the file’s encryption algorithm.

Why Windows rejects a correct password

A PFX or P12 file is encrypted with its password. The algorithm is chosen by the program that creates the file. OpenSSL 3 and current Windows versions use AES-256 with SHA-256 by default. Older Windows versions only know TripleDES with SHA-1.

Affected are Windows Server 2016, 2012 R2 and older, Windows 10 before version 1703, and Windows 8.1 and 7. They cannot decrypt the file and report it as a wrong password. Microsoft will not add AES-256 to Server 2016 and 2012 R2. The same happens on many Android devices, older Java versions and appliances.

Check how the file is encrypted

openssl pkcs12 -in certificate.pfx -info -noout

If the output shows PBES2, PBKDF2, AES-256-CBC and MAC: sha256, older Windows versions cannot read the file. With pbeWithSHA1And3-KeyTripleDES-CBC and MAC: sha1 all is fine. Without OpenSSL, the certificate converter shows a notice on loading when the file is AES-encrypted.

Fix in the browser

  1. Drop the PFX file into the certificate converter and enter the password.
  2. Choose “Cert + key (.p12/.pfx)” as the target format and set a new password.
  3. The new file is encrypted with 3DES/SHA-1 and can be imported on Windows Server 2016 and 2012 R2 too.

The conversion runs entirely in the browser; key and password never leave your computer.

Fix with OpenSSL

# Unpack the content (OpenSSL 3 reads AES files without trouble)
openssl pkcs12 -in new.pfx -nodes -out temp.pem
# Repackage compatibly: 3DES for key and certificates, SHA-1 for the MAC
openssl pkcs12 -export -in temp.pem -out compatible.pfx \
  -keypbe PBE-SHA1-3DES -certpbe PBE-SHA1-3DES -macalg sha1
# temp.pem contains the unencrypted key
rm temp.pem

There is also the -legacy switch. It needs OpenSSL’s legacy provider, which is not installed everywhere. The three switches above work with any OpenSSL 3 installation.

Fix on the newer Windows

If the file is exported on Windows Server 2019 or newer, you can pick the algorithm directly. In the export wizard the option is called “Encryption”; choose TripleDES-SHA1 instead of AES256-SHA256. With PowerShell:

$pw = Read-Host -AsSecureString "Password"
Get-ChildItem Cert:\LocalMachine\My\<thumbprint> |
  Export-PfxCertificate -FilePath C:\temp\compatible.pfx -Password $pw -CryptoAlgorithmOption TripleDES_SHA1

If it still fails

FAQ

Isn’t 3DES insecure?

The encryption only protects the file in transit. With a long, random password 3DES/SHA-1 is sufficient for that. After import the key lives in the Windows store and the file’s algorithm no longer matters. Delete the file afterwards.

Is there an update that adds AES-256 to Windows Server 2016?

No. Microsoft has confirmed that Windows Server 2016 and 2012 R2 will not get this support. The file has to be in the compatible format.

Does this affect IIS, Exchange and Remote Desktop too?

Yes. They all use the same Windows import. Once the file is in the compatible format, the import works in every wizard.

Sources and documentation