Skip to content

Issue with Lets Encrypt - Cloudflare #1566

Closed

Description

@luis-paulo-silva

Step template

Lets Encrypt - Cloudflare

Step version

No response

Octopus version

Any

Step template parameter inputs

No response

What happened

Duplicated certificate entries on the library due to a new CA being introduced and the step not updated

Reproduction steps

Just remove the current CAs (issuers) from the script and you should get the certificates duplicated.
Once they are duplicated (3 or 4 times), restore that list and try to update the certificates and get them replaced (it will not work)
You have to loop on the existing certificates to update them all to be archived and replaced by the new one.
We had this problem because we needed some custom code and the plugin was not up to date but the issue regarding replacing the certificates is still valid.

More Information

No response

Activity

  1. luis-paulo-silva commented on Oct 4, 2024

    @luis-paulo-silva
    Author

    Proposed fix:

    if ($expiring_certificates) {
            $expiring_certificates_count = $expiring_certificates.Count
            Write-Host "Found $expiring_certificates_count certificates that expire with $($OctopusParameters["LE_Cloudflare_ReplaceIfExpiresInDays"]) days. Requesting new certificates for $($LE_Cloudflare_CertificateDomain) from Lets Encrypt"
            $le_certificate = Get-LetsEncryptCertificate
    
            # PFX
            $existing_certificates = $certificates | Where-Object { $_.CertificateDataFormat -eq "Pkcs12" }
            $existing_certificates_count = $existing_certificates.Count
            Write-Host "Found $existing_certificates_count certificates to replace. Iterating..."
            $certificate_as_json = Get-ReplaceCertificatePFXAsJson -Certificate $le_certificate
            ForEach ($existing_certificate in $existing_certificates)
            {
              $certificateId = $existing_certificate.Id
              Write-Host "Replacing $certificateId with new certificate"
              Update-OctopusCertificate -Certificate_Id $existing_certificate.Id -JsonBody $certificate_as_json
            }
        }
    

    Edit:
    Additionally, if possible (and I'm looking to make it possible) the following array should be fetched from somewhere any time the step starts to avoid these problems.
    $LE_Cloudflare_Issuers = @("Let's Encrypt Authority X3", "E1", "E2", "R3", "R4", "R5", "R6", "R10", "R11")

    Instead of a static thing we should be getting it from an API somewhere.

  2. harrisonmeister commented on Aug 30, 2026

    @harrisonmeister
    Contributor

    Hey @luis-paulo-silva

    Thanks for raising this issue. I agree that this has been a long-standing (flawed) issue with these templates.

    As such, I raised #1701 to address this limitation, which I believe should handle the exact issue you raised here.

    Note: This doesnt resolve any duplicate certificates already issued. They'll need to be handled/archived and/or deleted separately.

    I'm going to close this issue for the reasons above, but please feel free to reopen if you think this issue is still unresolved after trying the latest versions of the Let's Encrypt step templates.

    Happy Deployments!

    Mark @ Octopus Deploy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions