The viya4-orders-cli command might fail with the following TLS certificate validation error when you try to retrieve a bearer token:
tls: failed to verify certificate: x509: certificate is valid for
apiproxy.sas.com, api.apiproxy.sas.com, management.apiproxy.sas.com,
portal.apiproxy.sas.com, not api.sas.com
This error occurs when the CLI attempts to connect to https://api.sas.com/mysas/token.
Here is an example:
[username@host ~]$ viya4-orders-cli_linux_amd64 deploymentAssets $ORDER $CADENCE $VERSION --file-path ~/path/to/zips
INFO: using config file: /home/username/.viya4-orders-cli.env
ERROR: Bearer token request failed:
Post "https://api.sas.com/mysas/token":
tls: failed to verify certificate: x509: certificate is valid for
apiproxy.sas.com, api.apiproxy.sas.com, management.apiproxy.sas.com,
portal.apiproxy.sas.com, not api.sas.com
This issue typically occurs when authentication credentials are missing, outdated, or not compatible with the current API authentication flow.
Complete the following steps to regenerate and configure credentials for the SAS® Viya® Orders API:
# Set temporary variable: Client ID from SAS Viya Orders API
CLIENT_ID="XXXXXXXXXXX"
# Set temporary variable: Client Secret from SAS Viya Orders API
CLIENT_SECRET="XXXXXXXXXXX"
# Write encoded values to config file
echo -n "apimClientCredentialsId: " >> ~/.viya4-orders-cli.env && echo -n "$CLIENT_ID" | base64 >> ~/.viya4-orders-cli.env
echo -n "apimClientCredentialsSecret: " >> ~/.viya4-orders-cli.env && echo -n "$CLIENT_SECRET" | base64 >> ~/.viya4-orders-cli.env
As an alternative, you can set credentials using environment variables:
# Set temporary variables
CLIENT_ID=""
CLIENT_SECRET=""
export APIMCLIENTCREDENTIALSID=$(echo -n "$CLIENT_ID" | base64)
export APIMCLIENTCREDENTIALSSECRET=$(echo -n "$CLIENT_SECRET" | base64)
Note: This method applies to only the current session unless added to a shell profile.