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:
- Create these objects:
- Application
- Certificate Request
- Machine
- Installation (Machine Identity)
- Perform these tasks:
- Get Users and Teams
- Encrypt credentials using Data Encryption Key (DEK)
- Initiate Workflow (Test connection)
- Initiate Workflow (Provisioning)
- Set/Update/Disable Provisioning schedule
Environment
VaaS/TLSPC TLSPC
Procedure
Using VenafiPS
- * Please note:
- You will need to update the values within the angle brackets to match your environment. For example:
-
BEFORE: $cred = '<api-key>' AFTER: $cred = '8d34bbfa-6ccb-43f5-9ff0-7666ed906d59'
-
- The command parameter "PassThru" is optional and returns the request details when supplied.
- You will need to update the values within the angle brackets to match your environment. For example:
- Authenticate your session:
-
$cred = '<api-key>' New-TrustClient -CmsKey $cred
-
- Get current Users:
-
Get-CmsUser -All
-
- Get current Teams:
-
Get-CmsTeam -All
-
- Create an Application:
-
$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})}
-
- Create Certificate Request:
-
New-TrustCertificate ` -CommonName '<common-name>' ` -Application '<application-name>' ` -IssuingTemplate '<issuing-template-name>' ` -PassThru
-
- Get Certificate Request details using ID:
-
Get-TrustCertificateRequest -CertificateRequest '<certificate-request-id>'
-
- Get Certificate details using ID:
-
Get-TrustCertificate -Certificate '<certificate-id>'
-
- Create a Machine:
-
# 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
-
- Get Machine details using name:
-
Find-TrustMachine -Name '<machine-name>'
-
- Get Machine details using ID:
-
Get-TrustMachine -Machine '<machine-id>'
-
- Update Machine name:
-
Set-TrustMachine ` -Machine '<machine-id>' ` -Name '<new-machine-name>'
-
- Create Installation (Machine Identity):
-
$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}}
-
- Get Machine Identity using name:
-
Find-TrustMachineIdentity -Machine '<machine-name>'
-
- Get Machine Identity using ID:
-
Get-TrustMachineIdentity -ID '<machine-identity-id>'
-
- Initiate Provisioning workflow:
-
Invoke-TrustWorkflow ` -Workflow Provision ` -ID '<machine-identity-id>'
-
- Initiate Test Connection workflow:
-
Invoke-TrustWorkflow ` -Workflow Test ` -ID '<machine-id>'
-
- Set or update the Machine Provisioning Schedule:
-
$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}}
-
- Disable Provisioning:
-
$machine_id = '<machine-id>' Invoke-TrustRestMethod ` -Method PATCH ` -UriLeaf "machines/$machine_id" ` -Body @{"batchProvisioningSchedulerEnabled"=$false} ` -Debug
-
- Process complete.
Using Certificate Manager - SaaS API
- Get currents Users:
-
curl --request GET \ --url https://api.venafi.cloud/v1/users \ --header 'accept: application/json' \ --header 'tppl-api-key: <api-key>'
-
- Get current Teams:
-
curl --request GET \ --url https://api.venafi.cloud/v1/teams \ --header 'accept: application/json' \ --header 'tppl-api-key: ••••'
-
- Create an Application:
-
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" } ] } '
-
- Create a Certificate Request:
-
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" } '
-
- Get Certificate Request details using ID:
-
# 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: ••••'
-
- Create a Machine:
- Get Data Encryption Key (DEK) ID
- Get VSatellite ID
- Get plugin ID
- Encrypt username and password with DEK to be used in final payload.
-
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" } } '
- Get Machine details using ID:
-
# 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'
-
- Update Machine name:
-
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" } '
-
- Create Installation (Machine Identity):
-
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" } } '
-
- Initiate Test Connection workflow:
-
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" } } '
-
- Initiate Provisioning workflow:
-
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" } '
-
- Set or update the Machine Provisioning Schedule:
-
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 } '
-
- Disable Provisioning:
-
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 } '
-
- Process complete.