How-To (Certificate Manager-SaaS): Create machines and applications using API and VenafiPS

How-To (Certificate Manager-SaaS): Create machines and applications using API and VenafiPS

166
Created On 11/10/26 10:55 AM - Last Modified 11/10/26 13:00 PM


Objective


This article covers how to create various objects in "Certificate Manager-SaaS" using both VenafiPS and CM - SaaS API. We will do the following:

 

  1. Create these objects:
    1. Application
    2. Certificate Request
    3. Machine
    4. Installation (Machine Identity)
  2. Perform these tasks:
    1. Get Users and Teams
    2. Encrypt credentials using Data Encryption Key (DEK)
    3. Initiate Workflow (Test connection)
    4. Initiate Workflow (Provisioning)
    5. Set/Update/Disable Provisioning schedule

 



Environment


VaaS/TLSPC TLSPC

Procedure


Using VenafiPS

  1. * Please note:
    1. You will need to update the values within the angle brackets to match your environment. For example:
      1. BEFORE: $cred = '<api-key>'
        AFTER: $cred = '8d34bbfa-6ccb-43f5-9ff0-7666ed906d59'
    2. The command parameter "PassThru"  is optional and returns the request details when supplied.
  2. Authenticate your session:
    1. $cred = '<api-key>'
      New-TrustClient -CmsKey $cred
  3. Get current Users:
    1. Get-CmsUser -All
  4. Get current Teams:
    1. Get-CmsTeam -All
  5. Create an Application:
    1. $app_name = '<application-name>'
      $owner_id = '<owner-id>'
      $owner_type = '<owner-type>' # Allowed: USER, TEAM, SERVICE_ACCOUNT
      Invoke-TrustRestMethod `
          -Method POST `
          -UriRoot 'outagedetection/v1' `
          -UriLeaf "applications" `
          -Body @{"name"=$app_name; "ownerIdsAndTypes"=@(@{'ownerType'=$owner_type;'ownerId'=$owner_id})}
  6. Create Certificate Request:
    1. New-TrustCertificate `
          -CommonName '<common-name>' `
          -Application '<application-name>' `
          -IssuingTemplate '<issuing-template-name>' `
          -PassThru
  7. Get Certificate Request details using ID:
    1. Get-TrustCertificateRequest -CertificateRequest '<certificate-request-id>'
  8. Get Certificate details using ID:
    1. Get-TrustCertificate -Certificate '<certificate-id>'
  9. Create a Machine:
    1. # Step 1 - Create secure credential object
      $passwordString = '<password>'
      $username = '<username>'
      $securePassword = $passwordString | ConvertTo-SecureString -AsPlainText -Force
      $myUser = New-Object System.Management.Automation.PSCredential($username, $securePassword)
      
      # Step 2 - Create IIS machine with Basic Auth
      New-TrustMachineIis `
          -Name '<machine-name>' `
          -Owner '<team-name>' `
          -Hostname '<host-name-or-ip>' `
          -Credential $myUser `
          -VSatellite '<vsatellite-name>'`
          -Status '<status>' `
          -Port '<port>' `
          -PassThru
  10. Get Machine details using name:
    1. Find-TrustMachine -Name '<machine-name>'
  11. Get Machine details using ID:
    1. Get-TrustMachine -Machine '<machine-id>'
  12. Update Machine name:
    1. Set-TrustMachine `
          -Machine '<machine-id>' `
          -Name '<new-machine-name>'
  13. Create Installation (Machine Identity):
    1. $machine_id = '<machine-id>'
      $certificate_id = '<certificate-id>'
      $site_name = '<iis-site-name>'
      $port = '<port>'
      $friendly_name = '<certificate-friendly-name>'
      $capi_store = '<certificate-store>'
      Invoke-TrustRestMethod `
          -Method POST `
          -UriLeaf '/machineidentities' `
          -Body @{"certificateId"=$certificate_id;"machineId"=$machine_id;"binding"=@{"port"=$port;"siteName"=$site_name};"keystore"=@{"friendlyName"=$friendly_name; "keystoreCapiStore"=$capi_store}}
  14. Get Machine Identity using name:
    1. Find-TrustMachineIdentity -Machine '<machine-name>'
  15. Get Machine Identity using ID:
    1. Get-TrustMachineIdentity -ID '<machine-identity-id>'
  16. Initiate Provisioning workflow:
    1. Invoke-TrustWorkflow `
          -Workflow Provision `
          -ID '<machine-identity-id>'
  17. Initiate Test Connection workflow:
    1. Invoke-TrustWorkflow `
          -Workflow Test `
          -ID '<machine-id>'
  18. Set or update the Machine Provisioning Schedule:
    1. $machine_id = '<machine-id>'
      $type = 'DAY_OF_MONTH'
      $day = 25
      $time = '00:00:00'
      Invoke-TrustRestMethod `
          -Method PATCH `
          -UriLeaf "machines/$machine_id" `
          -Body @{"batchProvisioningSchedulerEnabled"=$true;"batchProvisioningSchedulerPattern"=@{"recurrenceType"=$type; "daysOfMonth"=@($day); "recurrenceTime"=$time}}
  19. Disable Provisioning:
    1. $machine_id = '<machine-id>'
      Invoke-TrustRestMethod `
          -Method PATCH `
          -UriLeaf "machines/$machine_id" `
          -Body @{"batchProvisioningSchedulerEnabled"=$false} `
          -Debug
  20. Process complete.

Using Certificate Manager - SaaS API

  1. Get currents Users:
    1. curl --request GET \
           --url https://api.venafi.cloud/v1/users \
           --header 'accept: application/json' \
           --header 'tppl-api-key: <api-key>'
  2. Get current Teams:
    1. curl --request GET \
           --url https://api.venafi.cloud/v1/teams \
           --header 'accept: application/json' \
           --header 'tppl-api-key: ••••'
  3. Create an Application:
    1. curl --request POST \
           --url https://api.venafi.cloud/outagedetection/v1/applications \
           --header 'accept: application/json' \
           --header 'content-type: application/json' \
           --header 'tppl-api-key: ••••' \
           --data '
      {
        "name": "application-015",
        "ownerIdsAndTypes": [
          {
            "ownerType": "USER",
            "ownerId": "8c734ef0-fd30-11f0-9ba5-59fe2d87829d"
          }
        ]
      }
      '
  4. Create a Certificate Request:
    1. curl --request POST \
           --url https://api.venafi.cloud/outagedetection/v1/certificaterequests \
           --header 'accept: application/json' \
           --header 'content-type: application/json' \
           --header 'tppl-api-key: ••••' \
           --data '
      {
        "csrAttributes": {
          "commonName": "tester.cert.com"
        },
        "isVaaSGenerated": true,
        "applicationId": "b4d8e680-6b52-11f1-92df-1543180d8734",
        "certificateIssuingTemplateId": "5b3f2030-6b52-11f1-b329-671bce3dba31"
      }
      '
  5. Get Certificate Request details using ID:
    1. # In this case you update the URL  with the request ID and not the payload.
      
      curl --request GET \
           --url https://api.venafi.cloud/outagedetection/v1/certificaterequests/8b34b620-761e-11f1-ae62-b1a4e3f26f45 \
           --header 'accept: application/json' \
           --header 'tppl-api-key: ••••'
  6. Create a Machine:
    1. Get Data Encryption Key (DEK) ID
    2. Get VSatellite ID
    3. Get plugin ID
    4. Encrypt username and password with DEK to be used in final payload.
    5. curl --request POST \
           --url https://api.venafi.cloud/v1/machines \
           --header 'accept: application/json' \
           --header 'content-type: application/json' \
           --header 'tppl-api-key: ••••' \
           --data '
      {
        "owningTeamId": "1f88a7d0-6091-11f1-9863-81bbaabd62e4",
        "name": "Machine-777",
        "pluginId": "ca544416-40d8-46bc-89a5-21fd4dcbe483",
        "edgeInstanceId": "38463670-6b4f-11f1-a29f-c9f081458f8f",
        "dekId": "9iNtaVtgVyiV0ef1qqxc9Cu4asSrgguNcIZb_vPSWj4=",
        "status": "VERIFIED",
        "connectionDetails": {
          "protocolWinRm": {
            "port": 443
          },
          "username": "VOpWYW7sEb3xihRWRBcjeOCof/zLGMKgZtJOlxy59zVC5c7ds+opjH/N9VRgL4os0umENnVv7Bwq2Q==",
          "password": "2c2mZrjnQKAICILDlwAF2uGU8AGbpQK07y5EHwdQOFfbFRjaDFvvkQbx3TuCnGQoGIY/JmuJ1o+qvw==",
          "authenticationType": "basic",
          "credentialType": "local",
          "hostnameOrAddress": "192.168.198.230"
        }
      }
      '
  7. Get Machine details using ID:
    1. # In this case you update the URL  with the request ID and not the payload.
      
      curl --request GET \
           --url https://api.venafi.cloud/v1/machines/42eb4b20-7625-11f1-9456-53513f0546b5 \
           --header 'accept: application/json' \
           --header 'tppl-api-key: 930eaf2b-784e-4a09-b2cc-785fe6c3f65e'
  8. Update Machine name:
    1. curl --request PATCH \
           --url https://api.venafi.cloud/v1/machines/42eb4b20-7625-11f1-9456-53513f0546b5 \
           --header 'accept: application/json' \
           --header 'content-type: application/json' \
           --header 'tppl-api-key: 930eaf2b-784e-4a09-b2cc-785fe6c3f65e' \
           --data '
      {
        "name": "NewMachine"
      }
      '
  9. Create Installation (Machine Identity):
    1. curl --request POST \
           --url https://api.venafi.cloud/v1/machineidentities \
           --header 'accept: application/json' \
           --header 'content-type: application/json' \
           --header 'tppl-api-key: 930eaf2b-784e-4a09-b2cc-785fe6c3f65e' \
           --data '
      {
        "machineId": "42eb4b20-7625-11f1-9456-53513f0546b5",
        "binding": {
          "siteName": "example.site.com",
          "port": 443
        },
        "certificateId": "6dee2380-66ab-11f1-b5d2-7f255f4819a5",
        "keystore": {
          "friendlyName": "cert-friendly-name",
          "keystoreCapiStore": "Personal"
        }
      }
      '
  10. Initiate Test Connection workflow:
    1. curl --request POST \
           --url https://api.venafi.cloud/v1/machines/24b9f110-6b99-11f1-bb56-7d6c80a755ea/workflows \
           --header 'accept: application/json' \
           --header 'content-type: application/json' \
           --header 'tppl-api-key: 930eaf2b-784e-4a09-b2cc-785fe6c3f65e' \
           --data '
      {
        "workflowName": "testConnection",
        "workflowInput": {
          "wsClientId": "e833457f-5f61-4a8d-8e7a-5faee502ab88"
        }
      }
      '
  11. Initiate Provisioning workflow:
    1. curl --request POST \
           --url https://api.venafi.cloud/v1/machineidentities/6611bc50-6b9a-11f1-9f01-251999ab8bda/workflows \
           --header 'accept: application/json' \
           --header 'content-type: application/json' \
           --header 'tppl-api-key: 930eaf2b-784e-4a09-b2cc-785fe6c3f65e' \
           --data '
      {
        "workflowInput": {
          "wsClientId": "a7ade372-cf35-4544-a8fe-66f9dc14c28c"
        },
        "workflowName": "provisionCertificate"
      }
      '
  12. Set or update the Machine Provisioning Schedule:
    1. curl --request PATCH \
           --url https://api.venafi.cloud/v1/machines/24b9f110-6b99-11f1-bb56-7d6c80a755ea \
           --header 'accept: application/json' \
           --header 'content-type: application/json' \
           --header 'tppl-api-key: 930eaf2b-784e-4a09-b2cc-785fe6c3f65e' \
           --data '
      {
        "batchProvisioningSchedulerPattern": {
          "recurrenceType": "DAY_OF_MONTH",
      	"recurrenceTime":  "00:00:00",
          "daysOfMonth":  [25]
        },
        "batchProvisioningSchedulerEnabled": true
      }
      '
  13. Disable Provisioning:
    1. curl --request PATCH \
           --url https://api.venafi.cloud/v1/machines/24b9f110-6b99-11f1-bb56-7d6c80a755ea \
           --header 'accept: application/json' \
           --header 'content-type: application/json' \
           --header 'tppl-api-key: 930eaf2b-784e-4a09-b2cc-785fe6c3f65e' \
           --data '
      {
        "batchProvisioningSchedulerEnabled": false
      }
      '
  14. Process complete.


Actions
  • Print
  • Copy Link

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