Hello @Gonçalo Camacho,
The error "An error occurred while importing the certificate xxx" occurs due to various reasons like invalid certificate format, invalid password or if the certificate is not in PKCS#12 format.
To resolve the error, make sure the .pfx
file is in the correct format and is accepted by Azure Key Vault.
Note : Azure Key Vault expects the .pfx
file to be a valid PKCS#12 format. Hence make sure the certificate is in PKCS#12 format.
- Verify the
.pfx
file content:openssl pkcs12 -in file.pfx -info
- Also make sure you are passing the password correctly while importing the certificate.
I tried to import a .pfx
to Azure Key vault and its successful:
Sample generation of CER and PFX certificate using PowerShell:
$certname = "cert"
$cert = New-SelfSignedCertificate -Subject "CN=$certname" -CertStoreLocation "Cert:\CurrentUser\My" -KeyExportPolicy Exportable -KeySpec Signature -KeyLength 2048 -KeyAlgorithm RSA -HashAlgorithm SHA256
Export-Certificate -Cert $cert -FilePath "C:/Users/xxx/Downloads/$certname.cer" ## Specify your preferred location
$mypwd = ConvertTo-SecureString -String "password" -Force -AsPlainText
Export-PfxCertificate -Cert $cert -FilePath "C:/Users/xxx/Downloads/$certname.pfx" -Password $mypwd
Then export the certificate in "Manager user certificates" in the system.
Also, can you provide more details like how you generate or create the .pfx
certificate?
If you are still facing issue, I have reached out to you over private message so that I can guide you better for the particular step where you are failing. We can connect offline to resolve the issue.