- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
08-02-2018 06:49 AM
We have configured CCP client certificate auth and have the Windows browser and a MacOS browser pulling the credentials but are having trouble getting a PowerShell (Invoke-Rest-Method) or Python (Import Requests) script working. Does anyone have the syntax or a script that can pass either the cert or the thumbprint/SN via Python or Powershell?
The curl command working looks like this:
-Convert the .pfx to .cer
openssl pkcs12 -in /path/to/CERT_export.pfx -out /path/to/CERT_export.cer -nodes
Enter Import Password:
MAC verified OK
-Call the CCP
curl --request GET --url 'https://cyberark.com/AIMWebService/api/Accounts?AppID=<APPID>&Safe=<SAFE>&Folder=Root&Object=<OBJECT-NAME>' --header 'Content-Type: application/json' --cert '/PATH/TO/CERT_export.cer'
08-06-2018 06:09 AM
The code snippet option is enabled now. That is great! Thanks.
Just to close the loop on this thread, I will include the sample scripts I pasted earlier that work for CCP with Client Cert Auth:
# Declare Variables
$BASEURL="____"
$APPID="____"
$SAFE="____"
$FOLDER="____"
$OBJECT="____"
$THUMBPRINT="XXXXXXXXXXXXXXXXXXXXXXXXX"
# Call the CCP
Invoke-RestMethod -Uri "$BASEURL/AIMWebService/api/Accounts?AppID=$APPID&Safe=$SAFE&Folder=$FOLDER&Object=$OBJECT" -Method Get -CertificateThumbprint $THUMBPRINT
# Declare Variables
$BASEURL="____"
$APPID="____"
$SAFE="____"
$FOLDER="____"
$OBJECT="____"
$CERTPATH="____"
# Retrieve Certificate
$CERT=Get-PfxCertificate -FilePath $CERTPATH
# Call the CCP
Invoke-RestMethod -Uri "https://$BASEURL/AIMWebService/api/Accounts?AppID=$APPID&Safe=$SAFE&Folder=$FOLDER&Object=$OBJECT" -Method Get -CertificateThumbprint $CERT.ThumbPrint
08-02-2018 08:21 AM
I hope this is what you're looking for:
Invoke-RestMethod -Uri "https://cyberark.com/AIMWebservice/api/Accounts?AppID=<AppID>&Safe=<Safe>&object=<Object-Name>" -Method Get -CertificateThumbprint <Cert Thumbprint w/ no spaces>
08-03-2018 10:59 AM
Thanks for the reply. There must've been an issue with how the cert was imported because that syntax wasn't working but I have two versions that work now.
# Declare Variables
$BASEURL="____"
$APPID="____"
$SAFE="____"
$FOLDER="____"
$OBJECT="____"
$CERTPATH="____"
# Retrieve Certificate
$CERT=Get-PfxCertificate -FilePath $CERTPATH
# Call the CCP
Invoke-RestMethod -Uri "https://$BASEURL/AIMWebService/api/Accounts?AppID=$APPID&Safe=$SAFE&Folder=$FOLDER&Object=$OBJECT" -Method Get -CertificateThumbprint $CERT.ThumbPrint
2. This assumes that the cert is imported in the local machine personal store.
# Declare Variables
$BASEURL="____"
$APPID="____"
$SAFE="____"
$FOLDER="____"
$OBJECT="____"
$THUMBPRINT="XXXXXXXXXXXXXXXXXXXXXXXXX"
# Call the CCP
Invoke-RestMethod -Uri "$BASEURL/AIMWebService/api/Accounts?AppID=$APPID&Safe=$SAFE&Folder=$FOLDER&Object=$OBJECT" -Method Get -CertificateThumbprint $THUMBPRINT
08-03-2018 01:45 PM
Hi @James Stutes and @Peter Greenwood you can use now Code Snippet </> for getting better presentation of code:
# Declare Variables
$BASEURL="____"
$APPID="____"
$SAFE="____"
$FOLDER="____"
$OBJECT="____"
$THUMBPRINT="XXXXXXXXXXXXXXXXXXXXXXXXX"
# Call the CCP
Invoke-RestMethod -Uri "$BASEURL/AIMWebService/api/Accounts?AppID=$APPID&Safe=$SAFE&Folder=$FOLDER&Object=$OBJECT" -Method Get -CertificateThumbprint $THUMBPRINT
08-03-2018 02:00 PM
@Yaron Zorea How do you insert a code snippet? It doesn't look like I have that format option.
08-03-2018 02:11 PM
Hi @Peter Greenwood I have a different user license and permissions. I have checked it now with a the same user type that you are using and this option is not available.
I will investigate it next week and will update.
Thanks,
Yaron
08-06-2018 05:48 AM
Hi @Peter Greenwood ,
We have enabled code snippet for community users. Please let us know if it is working for you.
Yaron
08-06-2018 05:49 AM
--- Sample Code
# Declare Variables
$BASEURL="____"
$APPID="____"
$SAFE="____"
$FOLDER="____"
$OBJECT="____"
$THUMBPRINT="XXXXXXXXXXXXXXXXXXXXXXXXX"
# Call the CCP
Invoke-RestMethod -Uri "$BASEURL/AIMWebService/api/Accounts?AppID=$APPID&Safe=$SAFE&Folder=$FOLDER&Object=$OBJECT" -Method Get -CertificateThumbprint $THUMBPRINT
08-06-2018 06:09 AM
The code snippet option is enabled now. That is great! Thanks.
Just to close the loop on this thread, I will include the sample scripts I pasted earlier that work for CCP with Client Cert Auth:
# Declare Variables
$BASEURL="____"
$APPID="____"
$SAFE="____"
$FOLDER="____"
$OBJECT="____"
$THUMBPRINT="XXXXXXXXXXXXXXXXXXXXXXXXX"
# Call the CCP
Invoke-RestMethod -Uri "$BASEURL/AIMWebService/api/Accounts?AppID=$APPID&Safe=$SAFE&Folder=$FOLDER&Object=$OBJECT" -Method Get -CertificateThumbprint $THUMBPRINT
# Declare Variables
$BASEURL="____"
$APPID="____"
$SAFE="____"
$FOLDER="____"
$OBJECT="____"
$CERTPATH="____"
# Retrieve Certificate
$CERT=Get-PfxCertificate -FilePath $CERTPATH
# Call the CCP
Invoke-RestMethod -Uri "https://$BASEURL/AIMWebService/api/Accounts?AppID=$APPID&Safe=$SAFE&Folder=$FOLDER&Object=$OBJECT" -Method Get -CertificateThumbprint $CERT.ThumbPrint
07-16-2021 04:01 PM
Hi all,
This is my first time dealing with CCP Cert Authentication. When you say "This is assuming that certificate has been imported to your machines cert store." Do you mean the machine from where the call is being made or the CCP server?
Thank you in advance,
Douglas Galan
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!

