| name | a2a-workflow |
| description | Use when working on A2A (application-to-application) scripts, certificate authentication, credential retrieval, access request brokering, A2A service management, event subscriptions, or event discovery. |
A2A Workflow & Events
A2A (Application-to-Application) Overview
A2A allows applications to retrieve credentials (passwords, SSH keys, API key
secrets) from Safeguard without human interaction. The application
authenticates with a client certificate, not a user token.
Full A2A Setup Flow
- Generate a client certificate (key + cert PEM files)
- Install the certificate as a TrustedCertificate on the appliance
- Create a certificate user linked to the cert thumbprint
- Create an A2A registration linked to the certificate user
- Add accounts for credential retrieval (returns an API key per account)
- Use
get-a2a-password.sh with cert + key + API key to retrieve passwords
Scripted Example
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem \
-days 30 -nodes -subj "/CN=MyA2ACert"
cert_data=$(base64 -w 0 cert.pem)
invoke-safeguard-method.sh -s core -m POST -U "TrustedCertificates" \
-b "{\"Base64CertificateData\": \"$cert_data\"}"
thumbprint=$(openssl x509 -noout -fingerprint -sha1 -in cert.pem \
| cut -d= -f2 | tr -d :)
new-certificate-user.sh -n "MyCertUser" -s "$thumbprint"
new-a2a-registration.sh -n "MyApp" -C <certUserId>
add-a2a-credential-retrieval.sh -r <regId> -c <accountId>
echo "" | get-a2a-password.sh -a <appliance> -c cert.pem -k key.pem \
-A <apiKey> -p -r
Key API Details
TrustedCertificates
- Uses
Thumbprint as identifier (no numeric Id field) — use
jq -r '.Thumbprint' not .Id
- To delete:
DELETE TrustedCertificates/<thumbprint>
- Certificate data must be base64-encoded (no line wraps):
base64 -w 0
A2A Registrations
A2ARegistrations/{id}/RetrievableAccounts POST uses flat
{"AccountId": N} — not nested (opposite of AssetAccounts!)
- The POST response includes the
ApiKey needed for credential retrieval
- A2A password retrieval requires PolicyAdmin role to set up, but uses
certificate auth (not token auth) for actual retrieval
VisibleToCertificateUsers
A2A registrations need VisibleToCertificateUsers=true for cert-auth
listing via core/A2ARegistrations. Use the -V flag with
new-a2a-registration.sh. Without it, cert auth returns empty [].
new-a2a-registration.sh -n "MyApp" -C <certUserId> -V
Certificate Auth Stdin Pattern
get-a2a-password.sh and similar cert-auth scripts prompt for "Private Key
Password:". For passwordless keys, use -p and pipe an empty string:
echo "" | get-a2a-password.sh -a <appliance> -c cert.pem -k key.pem \
-A <apiKey> -p -r
The -r flag strips JSON quotes for raw password output.
Known Issue: PassStdin Not Used
Several cert-auth A2A scripts (e.g., get-a2a-password.sh,
get-a2a-privatekey.sh, set-a2a-password.sh) advertise -p for reading
the key password from stdin, but the parsed PassStdin variable is never
used in the curl command. They still prompt interactively. The echo "" |
workaround satisfies the prompt for passwordless keys.
A2A Service Must Be Enabled
The A2A service must be enabled before credential retrieval works:
enable-a2a-service.sh
get-a2a-service-status.sh
utils/a2a.sh Internals
The utils/a2a.sh library provides HTTP helpers for A2A cert-auth calls.
It includes an openssl fallback for systems where curl is linked against
GnuTLS (which has different cert handling than OpenSSL). The helper
constructs raw HTTPS requests via openssl s_client when needed.
Certificate Utility Scripts
These scripts in src/utils/ help with certificate generation and
conversion for A2A setup:
| Script | Description |
|---|
new-test-ca.sh | Generate a self-signed CA certificate + key |
new-test-cert.sh | Generate a certificate signed by a test CA |
convert-pfx-to-pem.sh | Convert PFX/PKCS12 to separate PEM files |
add-pem-password.sh | Add a password to a PEM private key |
remove-pem-password.sh | Remove a password from a PEM private key |
A2A Access Request Brokering
An A2A registration can also be configured as an access request broker, which
allows an application to create access requests on behalf of other users.
Setup Flow
- Create an A2A registration (steps 1-4 of the credential retrieval workflow)
- Configure the broker with authorized users/groups
- Use the broker API key with cert auth to create access requests
Example
set-a2a-access-request-broker.sh -i <regId> \
-b '{"Users": [{"UserId": 45}], "Groups": [{"GroupId": 10}]}'
get-a2a-access-request-broker.sh -i <regId>
echo "" | new-a2a-access-request.sh -a <appliance> -c cert.pem -k key.pem \
-A <brokerApiKey> -b '{
"ForUser": "jsmith",
"AssetName": "linux-server",
"AccountName": "root",
"AccessRequestType": "Password"
}' -p
clear-a2a-access-request-broker.sh -i <regId>
Key Details
- One broker per A2A registration (set replaces existing config)
- Broker body uses nested objects:
{"Users": [{"UserId": N}]} not flat arrays
- The broker API key is separate from credential retrieval API keys
new-a2a-access-request.sh uses cert auth (same pattern as get-a2a-password.sh)
- Supported AccessRequestType values:
Password, SSHKey, SSH,
RemoteDesktop, Telnet
Event Subscription Management
Event subscriptions configure how users receive notifications for Safeguard
events. Subscriptions can use SignalR (real-time) or email delivery.
new-event-subscription.sh -d "User changes" -T Signalr \
-e "UserCreated,UserModified"
get-event-subscription.sh
edit-event-subscription.sh -i <subId> -d "Updated description" \
-e "UserCreated"
find-event-subscription.sh -Q "user"
remove-event-subscription.sh -i <subId>
Event Discovery
Event discovery scripts help find subscribable events and their properties:
get-event-name.sh
get-event-name.sh -T User
get-event-name.sh -C UserAuthentication
get-event-category.sh
get-event-property.sh -n UserCreated
find-event.sh -Q "password"
find-event.sh -q "ObjectType eq 'Asset'"
Event Listeners & Handlers
For real-time event processing, safeguard-bash provides listener and handler
scripts that connect to Safeguard's SignalR endpoints:
| Script | Description |
|---|
listen-for-event.sh | Connect to SignalR and dump events to stdout |
handle-event.sh | Resilient event listener that invokes a handler script |
listen-for-a2a-event.sh | Connect to A2A SignalR events |
handle-a2a-password-event.sh | Handle A2A password change events |
handle-a2a-privatekey-event.sh | Handle A2A SSH key change events |
handle-a2a-apikeysecret-event.sh | Handle A2A API key secret change events |
handle-event.sh provides automatic reconnection with exponential backoff
(via utils/common.sh) for long-running event processing.