Export a certificate using API

Is there any way to export a certificate using the API? I see that you can get all kinds of information about a certificate, but, I don’t see a way to export the cert, or the actual cert data, to a file, or into a variable that can be passed to another resource for use. I’m needing this for a Terraform project, and I can’t run the apply using Octopus.

Hi @kevin101,

Welcome to the Octopus forums and thanks for the question.

You can get to the API Export by pointing at http://localhost/api/certificates/Certificates-1/export
Where Certificates-1 would be the certificate you wanted to export, you can easily check for the name here:

This export will prompt a download box in the browser.

In order to automate the save you can use a PowerShell script to Export instead, a simple example would be as follows:

$ApiKey = “API-***************”
$header = @{ “X-Octopus-ApiKey” = $APIKey }
Invoke-WebRequest -Uri “localhost/api/certificates/Certificates-1/export” -Headers $header | Out-File -FilePath “C:\Certificates\cert.pem” -Force

Please let me know if this is something you can utilize for your case.


This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.