CCP with Client Cert Auth from Linux

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CCP with Client Cert Auth from Linux

L2 Linker

I have a client need to call the CCP load balanced URL from a Linux server using certificate based authentication. I have the working Posh example from Windows, but wondering if anyone has gotten this to work from Linux.

1 accepted solution

Accepted Solutions

L3 Networker
#!/bin/bash # Variables URL="AAMServer.company.com" AIMWEB="AIMWebService" SAFE="SafeName" APPID="APPIDName" ACCOUNTOBJECTNAME="OBJECTID_NAME" Reason="REASONFORPASSWORDPULL" # Client certificate and key (update these paths as necessary) CLIENT_CERT="./client.pem" CLIENT_KEY="./privkey.pem" # Headers headers=("Content-Type: application/json") # Function to make the API request function get_account_info { # Create a temporary unencrypted key TEMP_KEY=$(mktemp) openssl rsa -in "$CLIENT_KEY" -out "$TEMP_KEY" response=$(curl -k --insecure -s -G "https://$URL/$AIMWEB/api/Accounts" \ --data-urlencode "AppID=$APPID" \ --data-urlencode "Safe=$SAFE" \ --data-urlencode "Object=$ACCOUNTOBJECTNAME" \ --data-urlencode "Reason=$Reason" \ -H "${headers[@]}" \ --cert "$CLIENT_CERT" \ --key "$TEMP_KEY") # Clean up the temporary key rm -f "$TEMP_KEY" echo "$response" } # Initial API call response=$(get_account_info) echo $response # Check if password change is in process password_change=$(echo "$response" | grep -o '"PasswordChangeInProcess": *"[^"]*"' | awk -F: '{print $2}' | tr -d ' "') # Extract Username and Password UserName=$(echo "$response" | grep -o '"UserName": *"[^"]*"' | awk -F: '{print $2}' | tr -d ' "') Password=$(echo "$response" | grep -o '"Content": *"[^"]*"' | awk -F: '{print $2}' | tr -d ' "') # Output results (optional) echo "Username: $UserName" echo "Password: $Password"

This should work for you

View solution in original post

2 REPLIES 2

L3 Networker
#!/bin/bash # Variables URL="AAMServer.company.com" AIMWEB="AIMWebService" SAFE="SafeName" APPID="APPIDName" ACCOUNTOBJECTNAME="OBJECTID_NAME" Reason="REASONFORPASSWORDPULL" # Client certificate and key (update these paths as necessary) CLIENT_CERT="./client.pem" CLIENT_KEY="./privkey.pem" # Headers headers=("Content-Type: application/json") # Function to make the API request function get_account_info { # Create a temporary unencrypted key TEMP_KEY=$(mktemp) openssl rsa -in "$CLIENT_KEY" -out "$TEMP_KEY" response=$(curl -k --insecure -s -G "https://$URL/$AIMWEB/api/Accounts" \ --data-urlencode "AppID=$APPID" \ --data-urlencode "Safe=$SAFE" \ --data-urlencode "Object=$ACCOUNTOBJECTNAME" \ --data-urlencode "Reason=$Reason" \ -H "${headers[@]}" \ --cert "$CLIENT_CERT" \ --key "$TEMP_KEY") # Clean up the temporary key rm -f "$TEMP_KEY" echo "$response" } # Initial API call response=$(get_account_info) echo $response # Check if password change is in process password_change=$(echo "$response" | grep -o '"PasswordChangeInProcess": *"[^"]*"' | awk -F: '{print $2}' | tr -d ' "') # Extract Username and Password UserName=$(echo "$response" | grep -o '"UserName": *"[^"]*"' | awk -F: '{print $2}' | tr -d ' "') Password=$(echo "$response" | grep -o '"Content": *"[^"]*"' | awk -F: '{print $2}' | tr -d ' "') # Output results (optional) echo "Username: $UserName" echo "Password: $Password"

This should work for you

This is wonderful! Much appreciated.

  • 1 accepted solution
  • 449 Views
  • 2 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

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!