1
votes

I generated pfx certificate using the following script:

openssl req -x509 -newkey rsa:4096 -sha256 -nodes -keyout security.key -out security.crt -subj "/CN=ourdomain.com" -days 3650
openssl pkcs12 -export -out security.pfx -inkey security.key -in security.crt -certfile security.crt

Next, i'm trying to add this certificate into our Azure Key Vault (into certificates section). After using this command:

$cer = Import-AzureKeyVaultCertificate -VaultName $vaultName -Name $certificateName -FilePath 'security.pfx' -Password $securepfxpwd

i get the following error:

Import-AzureKeyVaultCertificate : Private key is present in more than one item in certificate collection

This certificate is successfully used by our application and doesn't throw any errors in the process.

1

1 Answers

2
votes

First, you could generate a key as .pem file instead of .key file then convert PEM to PFX, try the following commands:

openssl req -x509 -newkey rsa:4096 -sha256 -nodes -keyout security.pem -out security.crt -subj "/CN=ourdomain.com" -days 3650
openssl pkcs12 -export -out security.pfx -inkey security.pem -in security.crt

This works on my side:

enter image description here

Details from Importing Certificates to Key Vault