I need to upload .pfx file to azure keyvault for using it in azure app gateway ssl purpose. When i upload the same .pfx file manually through UI i am able to upload. But for automation purpose i need this file to be fetched from key vault and hence i am trying to import it to azure keyvault but facing below error .
az keyvault certificate import --vault-name test -n test-vault -f test.pfx
(BadParameter) The specified PKCS#12 X.509 certificate content can not be read. Please check if certificate is in valid PKCS#12 format. Code: BadParameter Message: The specified PKCS#12 X.509 certificate content can not be read. Please check if certificate is in valid PKCS#12 format.
Command used to create pfx file
openssl pkcs12 -export -out test.pfx -inkey test.key -in test.crt
(BadParameter) The specified PKCS#12 X.509 certificate content can not be read. Please check if certificate is in valid PKCS#12 format. Code: BadParameter Message: The specified PKCS#12 X.509 certificate content can not be read. Please check if certificate is in valid PKCS#12 format.
The error message indicates that The .pfx
file may not be in the correct format expected by Azure Key Vault.
Azure Key Vault expects the .pfx
file to be a valid PKCS#12 format.
To verify the .pfx
file content, you can use the following command:
openssl pkcs12 -in test.pfx -info
If the .pfx
file is not in the correct format, you can recreate it using the following command:
openssl pkcs12 -export -out test.pfx -inkey test.key -in test.crt
I have tested this in my environment, and it was uploaded Successfully to Key Vault:
I've verified from Portal, here is the result from the portal: