Export Certificate in different formats

I’m curious if its possible to export the a certificate in different formats with the API. And is possible to password protect it?

Greetings Brian, thanks for reaching out :slight_smile: Octopus Deploy is written API-first, so anything you can do in the UI, you can do with an API call. In this case, the available formats for download are as follows

In regards to password protection, the only method that allows for setting a password is the PFX method. Here is an example of how to do this via PowerShell

# Declare variables
$octopusUrl = "https://YourServerURL"
$apiKey = "API-XXXXXXXXXXXXXXXXXXXXXX"
$header = @{ "X-Octopus-ApiKey" = $apiKey }
$pfxPassword = "MySuperPassword"
$fileLocation = "C:\temp\mycert.pfx"

# Download certificate
Invoke-RestMethod -Method Get -Uri "$octopusUrl/api/Spaces-1/certificates/certificates-demo-ssl-certificate-spaces-1/export?format=Pkcs12&password=$pfxPassword&includePrivateKey=false&pemOptions=PrimaryOnly" -OutFile $fileLocation -Headers $header

Hope this helps!

Regards,

Shawn

Exactly what I’m looking for! Thank you!

Awesome! Please let us know if we can be of any further help :slight_smile:

Regards,

Shawn

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