Skip to content
This repository has been archived by the owner on Jun 7, 2022. It is now read-only.

Creating Application and pushing to vaut #97

Closed
kp7425 opened this issue May 21, 2020 · 11 comments
Closed

Creating Application and pushing to vaut #97

kp7425 opened this issue May 21, 2020 · 11 comments

Comments

@kp7425
Copy link

kp7425 commented May 21, 2020

I am trying to creating an adaptable App and an existing certificate to it and push it to vault.

The application gets created in the right place with an error output on line 105.
-ProvisionCertificate is not pushing the cert to Vault.

New-TppObject -ProvisionCertificate -Path ('{0}\standalonecert123.test.com' -f $devicepath) -Class 'Adaptable App' -Attribute @{'Driver Name'='appadaptable';'Certificate'=$certpath;'Text Field 2'='secrets/test/data/testing/pushtest'} -ProvisionCertificate
Test-TppObject: /home/user/.local/share/powershell/Modules/VenafiTppPS/1.2.3/Public/New-TppObject.ps1:105
Line |
105 | … if ( -not (Test-TppObject -Path (Split-Path $Path -Parent) -ExistO …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot validate argument on parameter 'Path'. '/VED/Policy/Certificates/vcert/test-prod/vaultprod' is not a valid DN path

@kp7425
Copy link
Author

kp7425 commented May 21, 2020

The -ProvisionCertificate is not working may be due to the current version 18.2 . I get the DN error but the application gets created.

@gdbarron
Copy link
Owner

Hi @karthikpappu. I just checked the docs and looks like you are correct. The 'PushToNew' feature being utilized for certificate association when using -ProvisionCertificate was introduced in 18.3. I'll look to add something to the docs.

@kp7425
Copy link
Author

kp7425 commented May 21, 2020

@gdbarron Thank you for the quick reply. Not sure why I Am getting this error . Application is created and associated to a cert but getting the below error as invalid DN path

Test-TppObject: /home/user/.local/share/powershell/Modules/VenafiTppPS/1.2.3/Public/New-TppObject.ps1:105

Line |
105 | … if ( -not (Test-TppObject -Path (Split-Path $Path -Parent) -ExistO …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot validate argument on parameter 'Path'. '/VED/Policy/Certificates/vcert/test-prod/vaultprod' is not a valid DN path

@gdbarron
Copy link
Owner

Can you run with -verbose and provide the output please? Be sure to remove any sensitive data.

@kp7425
Copy link
Author

kp7425 commented May 22, 2020

Hello @gdbarron

'\VED\Policy\Certificates\vcert\dummy-env\vaultprod\standalonecert123.test.com'

vaultprod is a device
standalonecert123.test.com - is an adaptable application


PS /home/user/venafipowershell> New-TppObject -Path '\VED\Policy\Certificates\vcert\dummy-env\vaultprod\standalonecert123.test.com' -Class 'Adaptable App' -Attribute @{'Driver Name'='appadaptable';'Certificate'= '\VED\Policy\Certificates\vcert\dummy-env\standalonecert123.test.com'; 'Text Field 2'= $vaultpath } -Verbose
VERBOSE: ValidUntil: 5/22/2020 6:13:04 PM, Current (+2s): 5/22/2020 6:29:49 PM
VERBOSE: GET https://testserver.test.domain.com/vedsdk/authorize/checkvalid with 0-byte payload
VERBOSE: received 0-byte response of content type
VERBOSE: Unauthorized, re-authenticating
VERBOSE: {
"Uri": "https://testserver.test.domain.com/vedsdk/authorize",
"Body": "{\n "Password": "booooooo",\n "Username": "user01"\n}",
"Method": "Post",
"Headers": null,
"ContentType": "application/json"
}

VERBOSE: POST https://testserver.test.domain.com/vedsdk/authorize with 59-byte payload
VERBOSE: received 88-byte response of content type application/json
VERBOSE: Content encoding: utf-8
VERBOSE: {
"Uri": "https://testserver.test.domain.com/vedsdk/config/IsValid",
"Body": "{\n "ObjectDN": "\\VED\\Policy\\Certificates\\vcert\\dummy-env\\vaultprod\\standalonecert123.test.com"\n}",
"Method": "Post",
"Headers": {
"X-Venafi-Api-Key": "000000-0000000-000000-0000000"
},
"ContentType": "application/json"
}

VERBOSE: POST https://testserver.test.domain.com/vedsdk/config/IsValid with 102-byte payload
VERBOSE: received 147-byte response of content type application/json
VERBOSE: Content encoding: utf-8
Test-TppObject: /home/user/.local/share/powershell/Modules/VenafiTppPS/1.2.3/Public/New-TppObject.ps1:105
Line |
105 | … if ( -not (Test-TppObject -Path (Split-Path $Path -Parent) -ExistO …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~
| Cannot validate argument on parameter 'Path'. '/VED/Policy/Certificates/vcert/dummy-env/vaultprod' is not a valid DN path

VERBOSE: Performing the operation "Create Adaptable App Object" on target "\VED\Policy\Certificates\vcert\dummy-env\vaultprod\standalonecert123.test.com".
VERBOSE: {
"Uri": "https://testserver.test.domain.com/vedsdk/config/create",
"Body": "{\n "ObjectDN": "\\VED\\Policy\\Certificates\\vcert\\dummy-env\\vaultprod\\standalonecert123.test.com",\n "Class": "Adaptable App",\n "NameAttributeList": [\n {\n "Value": "secrets/team/data/test/powershellcert123",\n "Name": "Text Field 2"\n },\n {\n "Value": "appadaptable",\n "Name": "Driver Name"\n },\n {\n "Value": "\\VED\\Policy\\Certificates\\vcert\\dummy-env\\standalonecert123.test.com",\n "Name": "Certificate"\n }\n ]\n}",
"Method": "Post",
"Headers": {
"X-Venafi-Api-Key": "000000-0000000-000000-0000000"
},
"ContentType": "application/json"
}

VERBOSE: POST https://testserver.test.domain.com/vedsdk/config/create with 466-byte payload
VERBOSE: received 614-byte response of content type application/json
VERBOSE: Content encoding: utf-8
VERBOSE: Successfully created Adaptable App at \VED\Policy\Certificates\vcert\dummy-env\vaultprod\standalonecert123.test.com
VERBOSE: ValidUntil: 5/22/2020 6:32:24 PM, Current (+2s): 5/22/2020 6:29:51 PM
VERBOSE: {
"Uri": "https://testserver.test.domain.com/vedsdk/Certificates/Associate",
"Body": "{\n "CertificateDN": "\\VED\\Policy\\Certificates\\vcert\\dummy-env\\standalonecert123.test.com",\n "ApplicationDN": [\n "\\VED\\Policy\\Certificates\\vcert\\dummy-env\\vaultprod\\standalonecert123.test.com"\n ]\n}",
"Method": "Post",
"Headers": {
"X-Venafi-Api-Key": "000000-0000000-000000-0000000"
},
"ContentType": "application/json"
}

VERBOSE: POST https://testserver.test.domain.com/vedsdk/Certificates/Associate with 211-byte payload
VERBOSE: received 16-byte response of content type application/json
VERBOSE: Content encoding: utf-8

@gdbarron gdbarron mentioned this issue May 23, 2020
@gdbarron
Copy link
Owner

Thanks for the info. I believe the issue was due to a regex which only accepted \ instead of / which is used on Linux. Please give v1.2.4 a go and let me know how it goes.

@kp7425
Copy link
Author

kp7425 commented May 23, 2020

@gdbarron Thank you for the quick reply .

With 1.2.4 the application didn't get created and showing an error on line 106. With earlier version the application got created.

Error: The parent folder, /VED/Policy/Certificates/vcert/dummy-env/vaultprod, of your new object does not exist


PS /home/usert/venafipowershell> New-TppObject -Path '\VED\Policy\Certificates\vcert\dummy-env\vaultprod\standalonecert123.test.com' -Class 'Adaptable App' -Attribute @{'Driver Name'='appadaptable';'Certificate'= '\VED\Policy\Certificates\vcert\dummy-env\standalonecert123.test.com'; 'Text Field 2'= 'secrets/syseng/data/test/standalonecerttesting1234' } -Verbose
VERBOSE: ValidUntil: 5/23/2020 4:17:03 AM, Current (+2s): 5/23/2020 4:16:37 AM
VERBOSE: {
"ContentType": "application/json",
"Uri": "https://testserver.test.com/vedsdk/config/IsValid",
"Method": "Post",
"Headers": {
"X-Venafi-Api-Key": "c0cb4967-da03-f3a5-4a3a-2e1ad6deabce"
},
"Body": "{\n "ObjectDN": "\\VED\\Policy\\Certificates\\vcert\\dummy-env\\vaultprod\\standalonecert123.test.com"\n}"
}

VERBOSE: POST https://testserver.test.com/vedsdk/config/IsValid with 102-byte payload
VERBOSE: received 147-byte response of content type application/json
VERBOSE: Content encoding: utf-8
VERBOSE: ValidUntil: 5/23/2020 4:17:03 AM, Current (+2s): 5/23/2020 4:16:37 AM
VERBOSE: {
"ContentType": "application/json",
"Uri": "https://testserver.test.com/vedsdk/config/IsValid",
"Method": "Post",
"Headers": {
"X-Venafi-Api-Key": "c0cb4967-da03-f3a5-4a3a-2e1ad6deabce"
},
"Body": "{\n "ObjectDN": "/VED/Policy/Certificates/vcert/dummy-env/vaultprod"\n}"
}

VERBOSE: POST https://testserver.test.com/vedsdk/config/IsValid with 70-byte payload
VERBOSE: received 121-byte response of content type application/json
VERBOSE: Content encoding: utf-8
Exception: /home/usert/.local/share/powershell/Modules/VenafiTppPS/1.2.4/Public/New-TppObject.ps1:106
Line |
106 | throw ("The parent folder, {0}, of your new object does not e …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| The parent folder, /VED/Policy/Certificates/vcert/dummy-env/vaultprod, of your new object does not exist

@kp7425
Copy link
Author

kp7425 commented May 23, 2020

Ran Test-TppObject at it shows the path exists.

PS /home/user/venafipowershell> Test-TppObject -Path \VED\Policy\Certificates\vcert\dummy-env\vaultprod Object Exists


\VED\Policy\Certificates\vcert\dummy-env\vaultprod True

@gdbarron gdbarron reopened this May 23, 2020
@gdbarron
Copy link
Owner

The check for the parent path not existing was failing to validate if the path existed or not so it never stopped at that point. The code continued to create. Once I accounted for forward slashes in Linux, the check is now being validated and failing. This is why it worked before and isn't now.

The current issue is why is the check itself failing when you are saying the path exists. I don't have a working Linux system to test with right now so thanks for bearing with me. I've commented out those checks as they aren't truly needed as the api itself will fail. Please try again with v1.2.5 and let me know.

@kp7425
Copy link
Author

kp7425 commented May 23, 2020

@gdbarron Thank you for your continued support . After commenting out the check the ran without issues.

PS /home/users> Install-Module -Name VenafiTppPS -RequiredVersion 1.2.5 Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the
Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y
PS /home/users> Get-InstalledModule Version Name Repository Description ------- ---- ---------- ----------- 1.2.5 VenafiTppPS PSGallery PowerShell module to access the features of Venafi Trust Protection Pl…

PS /home/users> cd ./venafipowershell/
PS /home/users/venafipowershell>
PS /home/users/venafipowershell>
PS /home/users/venafipowershell>
PS /home/users/venafipowershell>
PS /home/users/venafipowershell>
PS /home/users/venafipowershell> $certobjects = Import-CSV ./applicationcreate.csv
PS /home/users/venafipowershell> #$certobjects
PS /home/users/venafipowershell> $cred = Get-Credential

PowerShell credential request
Enter your credentials.
User: vcert
Password for user vcert: ****************

PS /home/users/venafipowershell> New-TppSession -ServerUrl 'https://testserver.test.dummy.com' -Credential $cred
PS /home/users/venafipowershell>
PS /home/users/venafipowershell>
PS /home/users/venafipowershell> New-TppObject -Path '\VED\Policy\Certificates\vcert\dummy-env\vaultprod\standalonecert123.test.com' -Class 'Adaptable App' -Attribute @{'Driver Name'='appadaptable';'Certificate'= '\VED\Policy\Certificates\vcert\dummy-env\standalonecert123.test.com'; 'Text Field 2'= 'secrets/test/data/test/standalonecerttesting1234' } -Verbose
VERBOSE: ValidUntil: 5/23/2020 5:49:12 PM, Current (+2s): 5/23/2020 5:47:21 PM
VERBOSE: Performing the operation "Create Adaptable App Object" on target "\VED\Policy\Certificates\vcert\dummy-env\vaultprod\standalonecert123.test.com".
VERBOSE: {
"Body": "{\n "ObjectDN": "\\VED\\Policy\\Certificates\\vcert\\dummy-env\\vaultprod\\standalonecert123.test.com",\n "NameAttributeList": [\n {\n "Value": "secrets/test/data/test/standalonecerttesting1234",\n "Name": "Text Field 2"\n },\n {\n "Value": "appadaptable",\n "Name": "Driver Name"\n },\n {\n "Value": "\\VED\\Policy\\Certificates\\vcert\\dummy-env\\standalonecert123.test.com",\n "Name": "Certificate"\n }\n ],\n "Class": "Adaptable App"\n}",
"Headers": {
"X-Venafi-Api-Key": "000000-0000000-0000000-000000"
},
"Method": "Post",
"ContentType": "application/json",
"Uri": "https://testserver.test.dummy.com/vedsdk/config/create"
}

VERBOSE: POST https://testserver.test.dummy.com/vedsdk/config/create with 474-byte payload
VERBOSE: received 614-byte response of content type application/json
VERBOSE: Content encoding: utf-8
VERBOSE: Successfully created Adaptable App at \VED\Policy\Certificates\vcert\dummy-env\vaultprod\standalonecert123.test.com
VERBOSE: ValidUntil: 5/23/2020 5:49:12 PM, Current (+2s): 5/23/2020 5:47:22 PM
VERBOSE: {
"Body": "{\n "CertificateDN": "\\VED\\Policy\\Certificates\\vcert\\dummy-env\\standalonecert123.test.com",\n "ApplicationDN": [\n "\\VED\\Policy\\Certificates\\vcert\\dummy-env\\vaultprod\\standalonecert123.test.com"\n ]\n}",
"Headers": {
"X-Venafi-Api-Key": "000000-0000000-0000000-000000"
},
"Method": "Post",
"ContentType": "application/json",
"Uri": "https://testserver.test.dummy.com/vedsdk/Certificates/Associate"
}

VERBOSE: POST https://testserver.test.dummy.com/vedsdk/Certificates/Associate with 211-byte payload
VERBOSE: received 16-byte response of content type application/json
VERBOSE: Content encoding: utf-8
PS /home/users/venafipowershell>

@gdbarron
Copy link
Owner

Awesome, glad it's working.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants