brent-robinson / posh-acme-azure-example

Example using the Posh-ACME PowerShell module to orchestrate TLS certificate issuance using ACME in Azure with Azure DevOps
https://medium.com/@brentrobinson5/automating-certificate-management-with-azure-and-lets-encrypt-fee6729e2b78
MIT License
30 stars 27 forks source link

Script not compatible with Posh-ACME version 4.7.0 or above #4

Open Johno-ACSLive opened 3 years ago

Johno-ACSLive commented 3 years ago

I've had the script fail in Azure DevOps, version 4.6.0 is the last version that enables successful renewals of certificates. Any version above 4.7.0 does not.

The failure occurs with Import-AcmeCertificateToKeyVault.ps1:35

Line | 35 | … rtificate = New-Object -TypeName System.Security.Cryptography.X509Cer … | ~~~~~~~~~~~~~ | Exception calling ".ctor" with "3" argument(s): "The | certificate data cannot be read with the provided password, | the password may be incorrect."

It appears the library went through quite a big change in version 4.7.0 but I haven't had time to check the details of what's changed. I've temporarily updated the script in my repo to only download version 4.6.0 of Posh-ACME until more is known of the breaking changes.

heathen1878 commented 2 years ago

Try using Get-PfxCertificate...this worked for me.

Johno-ACSLive commented 2 years ago

Still had the same error, appears the Get-PAOrder requires to be in the following syntax.

$pfxPass = (Get-PAOrder -Name $certificateName).PfxPass

The original doesn't specify which parameter to be assigned. Adding the -Name in front fixes the problem alongside your recommendation (I didn't try the original code - assuming it would also continue to work as well).

I made a few other changes so I'll post a PR with the complete changes.