I use these command to create new certificates on windows
$cert = New-SelfSignedCertificate -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" -KeyAlgorithm RSA -KeyLength 2048 -certstorelocation cert:localmachinemy -dnsname dkim -NotAfter (Get-Date).AddYears(5)
$pwd = ConvertTo-SecureString -String 'qwerty' -Force -AsPlainText
$path = 'cert:localMachinemy' + $cert.thumbprint
Export-PfxCertificate -cert $path -FilePath c:tempdkim.pfx -Password $pwd
and the certificate geberated with this works in my asp.net application for dkim signing enails with rsa256.
I need to create a new certificate using the existing key of an existing certificate
https://learn.microsoft.com/en-us/powershell/module/pki/new-selfsignedcertificate?view=windowsserver2022-ps
this document of Microsoft says that I can do it using the parameter -ExistingKey
but I am not able to achieve, can someone help me.
I tried using opensll, converting exisitng certificate to pem and then using its key for creating the new certificate but doesn’t works with my application.
Anil Bind is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.