Info: How To Upload a Certificate and Private Key To TLS Protect Cloud

Info: How To Upload a Certificate and Private Key To TLS Protect Cloud

215
Created On 11/10/26 11:00 AM - Last Modified 11/10/26 16:02 PM


Symptom


Applies To

TLS Protect Cloud

 

Summary

How to upload a certificate along with it's private key to TLS Protect Cloud

 

More Information

Currently, the only way to upload a certificate with its private key into TLS Protect Cloud is via an API call. There are two options to complete this process.

  • The VenafiPS module
  • A series of API calls and a Python script

VenafiPS Module

Pre-Requisites

  • Certificate keystore in the pkcs#12 format
  • PowerShell
  • TLS Protect Cloud API Key See our documentation
  • VenafiPS Powershell Module

Venafi has a PowerShell module that is published on the PowerShell Gallery. Powershell is already installed on Windows, and is also available on MacOS and Linux as PowerShell Core. Follow the links for your OS if you need to install PowerShell Core

To install the VenafiPS tool run the following command in Powershell:

Install-Module -Name VenafiPS

Once VenafiPS is installed we can begin the process. We will perform the following steps.

Importing the PKCS#12 Keystore

  1. In a PowerShell session, run the following command to create a new Venafi Session replacing the placeholder with your API Key
    New-VenafiSession -VaaSKey <API Key>
  2. Next, run the following command to start the import process.
    Import-VcCertificate
  3. This will prompt you for the path to the certificate. Enter the absolute path to the certificate file.
  4. Next, it will prompt you for the private key password. Enter that here.
  5. Finally it will import the certificate and return a status of IMPORTED if successful.

Here is an example of the process (API Key and fingerprint have been redacted).

Screenshot 2024-03-07 at 2.41.21PM.png

Note: In more recent versions of VenafiPS, the command to import is as below:

 

Import-VcCertificate -CertificatePath <PathToFile/Filename.pfx> -PrivateKeyPassword '<Password>'

 

Where PathToFile is the path where the certificate is stored, Filename.pfx is the name of the file and Password is the private key password.

API and Python Script

Pre-Requisites

  • Must have at least 1 active vSatellite
  • Must have an admin API key from your account. See our documentation
  • The full certificate chain must be installed in TLS Protect Cloud for all keys and certs prior to import. See our documentation
  • Certificate and key must be in PKCS#12 format and the password for the keystore is needed.
  • Python3 installed to run a python script

 

Gather Information from TLS Protect Cloud

You will need a couple pieces of information from TLS Protect Cloud which we will get from a recipe from Dev Central. That recipe can be found here: Import Private Key into TLS Protect Cloud

  1. Copy the recipe and paste it into a text file and save it as ImportRecipe.py.
  2. In this recipe, on line 19 that shows TLSPC_API_KEY, you will need to replace the placeholder "x"s with your API Key and save the file. It should look similar to the following (A portion of the key has been redacted):Screenshot 2024-03-07 at 1.13.01PM.png
  3. Next, we will run this script with the following command ran in a terminal that is in the location of the script.
    python3 ./ImportRecipe.py
  4. After you run the file, it will prompt you saying "Enter value you want to DEK encrypt:" here you will enter the private key password and hit enter
  5. The script will show you 3 values that we will need to import the certificate and private key, your Edge Instance ID, your Encryption Key ID and your DEK Encrypted value which is your password that has been encrypted by the vSatellite DEK. Gather all values and save them for use in the API call we will be making. The script will ask you if you want to encrypt another value. Type "n" and hit enter. The script will end.
  6. Next, we will encode our PKCS#12 certificate to a base64 format needed for import. In a terminal/command prompt run the following command with the path to the certificate file. This will return a large base64 value that you will need to copy and save for the import call we will be making.
    base64 -i <path/to/cert>

Populate and run the API call

Now it is time to import the certificate. Here is the call that we will be making:

curl --location 'https://api.venafi.cloud/outagedetection/v1/certificates/imports
' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'tppl-api-key: <your API Key>' \
--data '{
"importInformation": [
{
"pkcs12Keystore": " < your base64 encoded certificate >",
"dekEncryptedPassword": " < your DEK encrypted password > "
}
],
"edgeInstanceId": " < your edgeInstanceId > ",
"encryptionKeyId": " < your encryptionKeyId > "
}'

We will need to modify the following values:

  1. tppl-api-key: add your API Key in place of the placeholder
  2. pkcs12Keystore: replace the placeholder with the base64 value we received in step 6
  3. dekEncryptedPassword: replace the placeholder with the "DEK Encrypted value" that was returned in step 5
  4. edgeInstanceId: replace the placeholder with the "Edge Instance ID" value that was returned in step 5
  5. encryptionKeyId: replace the placeholder with the "Encryption Key ID" value that was returned in step 5

If the import request is successful, you will receive a response similar to the following:

{
"id": " < query id here > "
"creationDate": " < timestamp of the query > "
}

We can use the "id" value to look into the status of the import.

 

API Status Query

To view the status of an import query, you can run a query against the endpoint with the id from your import query response. Here is an example of the query:

curl --location 'https://api.venafi.cloud/outagedetection/v1/certificates/imports/<your import job id>' \
--header '< your API key >: tppl-api-key'

When running this query, the response should have a field called "status" which will show the current status of the import job.



Environment


TPP/TLSPDC

Actions
  • Print
  • Copy Link

    https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA1hj0000001FhrCAE&lang=en_US&refURL=http%3A%2F%2Fknowledgebase.paloaltonetworks.com%2FKCSArticleDetail