Skip to content

Commit 4009e1b

Browse files
authored
Merge pull request #374 from Venafi/371-new-vdccertificate--timeoutsec
reviewed offline
2 parents 5328bab + c05c20f commit 4009e1b

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

VenafiPS/Public/New-VdcCertificate.ps1

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ function New-VdcCertificate {
44
Enrolls or provisions a new certificate
55
66
.DESCRIPTION
7-
Enrolls or provisions a new certificate.
8-
Prior to TLSPDC 22.1, this function is asynchronous and will always return success.
9-
Beginning with 22.1, you can control this behavior.
10-
See https://docs.venafi.com/Docs/currentSDK/TopNav/Content/SDK/WebSDK/r-SDK-Certificates-API-settings.php.
7+
Enrolls or provisions a new certificate
118
129
.PARAMETER Path
1310
The folder DN path for the new certificate.
@@ -68,8 +65,11 @@ function New-VdcCertificate {
6865
See the example.
6966
7067
.PARAMETER TimeoutSec
71-
Introduced in 22.1, this controls the wait time, in seconds, for a CA to issue/renew a certificate.
72-
The default is 60 seconds.
68+
Control the wait time, in seconds, for a CA to issue/renew a certificate.
69+
Can be set globally in the product, https://docs.venafi.com/Docs/currentSDK/TopNav/Content/SDK/WebSDK/r-SDK-Certificates-API-settings.php.
70+
Use this as an override to the global setting.
71+
The product default of 0 will cause this function to return immediately, before the certificate has been created.
72+
This property is useful if you are wanting to immediately access the certificate when New-VdcCertificate is finished, eg. to pipe to Export-VdcCertificate.
7373
7474
.PARAMETER PassThru
7575
Return an object representing the newly created certificate.
@@ -83,7 +83,7 @@ function New-VdcCertificate {
8383
None
8484
8585
.OUTPUTS
86-
TppObject, if PassThru is provided
86+
PSCustomObject, if PassThru is provided
8787
If devices and/or applications were created, a 'Device' property will be available as well.
8888
8989
.EXAMPLE
@@ -114,6 +114,11 @@ function New-VdcCertificate {
114114
New-VdcCertificate -Path '\ved\policy\folder' -Name 'mycert.com' -Device @{'PolicyDN'=$DevicePath; 'ObjectName'='MyDevice'; 'Host'='1.2.3.4'} -Application @{'DeviceName'='MyDevice'; 'ObjectName'='BasicApp'; 'DriverName'='appbasic'}
115115
Create a new certificate with associated device and app objects
116116
117+
.EXAMPLE
118+
New-VdcCertificate -Path '\ved\policy\certs' -Name 'www.barron.com' -CertificateAuthorityPath '\ved\policy\CA Templates\my template' -TimeoutSec 30 -PassThru | Export-VdcCertificate -PKCS12 -PrivateKeyPassword 'mySecretPassword!'
119+
120+
Wait up to 30 seconds for the CA to create the certificate and then export it
121+
117122
.LINK
118123
https://venafi.github.io/VenafiPS/functions/New-VdcCertificate/
119124
@@ -197,7 +202,8 @@ function New-VdcCertificate {
197202

198203
[Parameter()]
199204
[Alias('WorkToDoTimeout')]
200-
[int32] $TimeoutSec = 60,
205+
[ValidateRange(0, 120)]
206+
[int32] $TimeoutSec,
201207

202208
[Parameter()]
203209
[switch] $PassThru,
@@ -311,7 +317,9 @@ function New-VdcCertificate {
311317
$params.Body.Add('ManagementType', [enum]::GetName([TppManagementType], $ManagementType))
312318
}
313319

314-
$params.Body.Add('WorkToDoTimeout', $TimeoutSec)
320+
if ( $PSBoundParameters.ContainsKey('TimeoutSec') ) {
321+
$params.Body.Add('WorkToDoTimeout', $TimeoutSec)
322+
}
315323

316324
if ( $PSBoundParameters.ContainsKey('SubjectAltName') ) {
317325
$newSan = @($SubjectAltName | ForEach-Object {
@@ -378,9 +386,9 @@ function New-VdcCertificate {
378386

379387
if ( $PassThru ) {
380388
$newCert = Get-VdcObject -Path $response.CertificateDN
381-
if ( $Device ) {
389+
if ( $response.Devices.DN ) {
382390
$newCert | Add-Member @{ 'Device' = @{'Path' = $response.Devices.DN } }
383-
if ( $Application ) {
391+
if ( $response.Devices.Applications.DN ) {
384392
$newCert.Device.Application = $response.Devices.Applications.DN
385393
}
386394
}

VenafiPS/VenafiPS.psm1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ $vdcPathArgCompleterSb = {
174174

175175
}
176176
}
177-
Register-ArgumentCompleter -CommandName $vdcCommands -ParameterName 'Path' -ScriptBlock $vdcPathArgCompleterSb
177+
'Path', 'CertificateAuthorityPath', 'CredentialPath', 'CertificatePath', 'ApplicationPath', 'EnginePath', 'CertificateLinkPath', 'NewPath' | ForEach-Object {
178+
Register-ArgumentCompleter -CommandName $vdcCommands -ParameterName $_ -ScriptBlock $vdcPathArgCompleterSb
179+
}
178180

179181
$vcLogArgCompleterSb = {
180182
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)

0 commit comments

Comments
 (0)