Error when Importing Certificate

Gonçalo Camacho 0 Reputation points
2025-03-26T17:55:15.6666667+00:00

Hello,

Hope you guys are doing great,

I'm currently trying to update a certificate in our keyvaults, I have the certificate in PFX format and it's password protected. Although the keyvault it's stating that an error occurred while importing the certificate.
User's image

Do you have any ideas why this issue is occurring?

Waiting on your feedback.

Best Regards
Gonçalo

Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
1,411 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Rukmini 1,171 Reputation points Microsoft External Staff
    2025-04-01T07:58:09.7633333+00:00

    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:

    enter image description here

    enter image description here

    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.