Android says “incorrect password” when importing a certificate

The password is right, Android claims otherwise. The cause is almost never the password but the file’s encryption: OpenSSL 3 creates PKCS#12 files with AES-256, and many Android versions cannot read them. The error message is simply misleading.

How to recognize the problem

Typically affected are client certificates for OpenVPN and strongSwan, and for company Wi-Fi with EAP-TLS.

The cause

Up to OpenSSL 1.1, PKCS#12 files were protected with older methods (3DES or RC2, checksum with SHA-1). Since OpenSSL 3.0 the default is AES-256-CBC with PBKDF2 and SHA-256. That is more secure, but many Android versions, older macOS and Windows versions and some appliances don’t understand the format. Instead of “format not supported” they report “incorrect password”.

Check the file

openssl pkcs12 -info -in client.p12 -noout

If it shows PBES2, PBKDF2, AES-256-CBC, it is the new format. With pbeWithSHA1And3-KeyTripleDES-CBC the file is in the old, compatible format and the problem is elsewhere, see below.

Fix 1: export again with -legacy

openssl pkcs12 -export -legacy -in client.crt -inkey client.key -certfile ca.crt -out client-android.p12

If OpenSSL reports unsupported, the legacy provider is missing. Then use 3DES, which OpenSSL 3 supports by default:

openssl pkcs12 -export -in client.crt -inkey client.key -certfile ca.crt \
  -keypbe PBE-SHA1-3DES -certpbe PBE-SHA1-3DES -macalg sha1 -out client-android.p12

Fix 2: convert an existing .p12

If you only have the finished file, unpack it and pack it again:

openssl pkcs12 -in client.p12 -nodes -out temp.pem
openssl pkcs12 -export -legacy -in temp.pem -out client-android.p12
rm temp.pem    # contains the key unencrypted

Fix 3: in the browser, without OpenSSL

The certificate converter always creates .p12 files in the compatible format (3DES, SHA-1). You can give it an existing .p12 and output a new .p12, or paste certificate, key and chain separately. If the intermediate is missing, it completes the chain on request. The files never leave your computer.

Install on Android

Since Android 11 this only works via Settings, no longer by tapping the file: Settings → Security → More security settings → Encryption & credentials → Install a certificate. Choose “VPN & app user certificate” for VPN apps or “Wi-Fi certificate” for company Wi-Fi. On Samsung and other brands the menus are named slightly differently; searching Settings for “certificate” helps.

If it still doesn’t work

FAQ

Is the old format insecure?

3DES with SHA-1 is weaker than AES-256, but still protects the file decently, especially with a long password. What matters is deleting the .p12 from the device after import and not sending it unencrypted.

Does this affect iPhone and Mac too?

Yes, older macOS and iOS versions also report a wrong password for AES-protected files, often as “MAC verification failed”. The fix is the same.

Which Android versions are affected?

There are reports from Android 10 to 13, depending on vendor and update level. A file in the old format works on all versions, which makes it the safe choice for Android.

Sources and documentation