Factors That Influence The API Key Length
Symptom
Factors influencing the API key length on PanOS platforms.
Environment
- Palo Alto Firewalls
- PAN-OS 9.0 and above
- API Key
Cause
API Key length changes for specific username and password combinations.
Resolution
- On PAN-OS platforms for making API calls, an API key must be generated, in order to make authenticated API calls.
- In most situations, an API key is of length 132 characters. However, there are certain instances wherein this can vary and an even longer key of length 164 characters is generated.
- The user input for generating the API key is primarily the username and password of the device.
- This username/password is used to generate the API key and hence depending on how many characters the username and password (in total) contains the API key length can vary.
- The API key of length 132 characters is achieved only if the total number of characters in the username and password combination is below 26 characters.
- If the character count on the username and password combination is 27 or above the resulting API key length will be 164 characters.
- Examples are provided in the additional information section.
Additional Information
How to get the API key:
Case 1: Username and Password is "api" and "password". Total character count is (api+password) = 11.
#curl -k -X GET 'https://<ip_address>/api/?type=keygen&user=api&password=password'
<response status = 'success'>
<result>
<key>
LUFRPT1qQlFPKzMwcWloSXRjT2dMQ2p1T2k5VVR0cmc9QXIvT3BhL3gxUWVYS1VMWmNNc29oY2d4VmhrVEgzU2FMbnZ0ZlhBWDBQZ0R5bDlheHNDUjZqTHVkQW1IYnpaZA==
</key>
</result>
</response>
The resulting API key length is 132 characters.
Case 2: Username and Password is "api" and "abcdefghijklmnopqrstuvw". Total character count is 26.
#curl -k -X GET 'https://<ip_address>/api/?type=keygen&user=api&password=abcdefghijklmnopqrstuvw'
<response status = 'success'>
<result>
<key>
LUFRPT1xWHJlTzI3bWtVYURsSmJ4N3Z3d0grY3ZsYTg9WGIzSEZqQ0JxeXVsVmxKWUhSMTNkSDlHSW41dG5YWnlnaHVNYXZyOFVKWGNkWjZ0U0xwMTJsL2RzT20wMGRXbQ==
</key>
</result>
</response>
The resulting API key length is 132 characters.
Case 3: Username and Password is "api" and "abcdefghijklmnopqrstuvwx". Total character count is 27.
#curl -k -X GET 'https://<ip_address>/api/?type=keygen&user=api&password=abcdefghijklmnopqrstuvwx'
<response status = 'success'>
<result>
<key>
LUFRPT15RDVCTm5uc3U2V0s0TFMzMlQ5SExWeFNnWHM9WGIzSEZqQ0JxeXVsVmxKWUhSMTNkQUJwd3QrcjB3RVl0QW9NS0puVkQ2eG1WMnl5RDZzbDZSbVBoQk9td2F0SmxmdXhOWXo2ekZqYmZiMEVjUHJReUE9PQ==
</key>
</result>
</response>
The resulting API key length is 164 characters.
Case 4: Username and Password is "apiuser" and "abcdefghijklmnopqrs". The total character count is 26.
#curl -k -X GET 'https://<ip_addresss>/api/?type=keygen&user=apiuser&password=abcdefghijklmnopqrs'
<response status = 'success'>
<result>
<key>
LUFRPT1aalI0MW56NXBaQi9UcjBuS3MrY3ZNYkxrOXc9ZmdxYUNmR3hFQUFwb0VIRE1sLytsYStRSDYzeGxMZWhDQzJjTEFWN2NZN3hib1FWb0JMc1FVS0FqelBCV2FPeg==
</key>
</result>
</response>
The resulting API key length is 132 characters.
Case 5: Username and Password is "apiuser" and "abcdefghijklmnopqrst". The total character count is 27.
#curl -k -X GET 'https://<ip_address>/api/?type=keygen&user=apiuser&password=abcdefghijklmnopqrst'
<response status = 'success'>
<result>
<key>
LUFRPT1HbEk4dzNsWUYxc1lzSEQ4TlRrdjZYMmtYekk9ZmdxYUNmR3hFQUFwb0VIRE1sLytsVC9OQm9GaDlpS0p3QWdaVWw5Tk94T1pWRndxQUVWbTFVVlZwOHJRMDZsbmtrWEo3NWsxajcrcUF1bnNXRVFSMmc9PQ==
</key>
</result>
</response>
The resulting API key length is 164 characters.