Troubleshooting Tip: How to resolve 'Cannot find key for' error in Kerberos authentication
| Description | This article describes how to handle the error 'Cannot find key for' the principal in Kerberos authentication. |
| Scope | FortiGate, FortiProxy. |
| Solution | Kerberos authentication fails when it cannot locate the correct key for the principal in the FortiGate device.
When attempting to connect via Kerberos Authentication, collecting the WAD debug generates the following error:
[I][p:221][s:1956622081][r:16777808] wad_krb_err_print :46 Error returned by gss_accept_sec_con [I][p:221][s:1956622081][r:16777808] wad_http_auth_status_proc :9968 authenticate result=failure
This issue occurs when the password for the service account is changed. Every time the password is changed, the KVNO value will increment by 1, resulting in a difference with the KVNO value of the already uploaded keytab previously. This can be validated from AD by running the command below in Windows PowerShell:
Get-ADUser -identity testproxy -Properties msDS-KeyVersionNumber
The value "msDS-KeyVersionNumber" in output corresponds to the current KVNO value in AD
To check the current version in the keytab file, an external software such as MIT Kerberos can be used to decode the file, which can be obtained from the following link:
From cmd the following command can be used. Only the .keytab file is used:
klist -k -t fgt.keytab
To resolve this issue, remove the existing keytab from the FortiGate and generate a new one on the server using the ktpass command:
ktpass -princ HTTP/fortigate2K.abc.com@ABC.COM -mapuser <user> -pass <password> -crypto all -ptype KRB5_NT_PRINCIPAL -out fgt.keytab
Note that the user in the above command is the service account created in the AD, and the password is the password for the service account.
To check if the keytab is successfully imported and decoded, use the command below:
fnsysctl ls -la /tmp/kt
Note: The keytab file is no longer visible starting from v7.4.5 due to identified security concerns.
fnsysctl ls -la /tmp/kt
Make sure the principal entered in the config user krb-keytab section exactly matches the one used in the ktpass command when generating the keytab file. Ensure that the base64-encoded keytab file on the server is merged into a single continuous line; otherwise, the import to FortiGate will not be successful.
Before retrying, purge the klist on the end user machine by using the following command:
klist purge
After, clear the user's browser cache and cookies.
Related article: |
