Skip to main content
KC_Hing
Staff
Staff
November 5, 2024

Technical Tip: Unable to regenerate a keytab file

  • November 5, 2024
  • 0 replies
  • 1848 views
Description

This article describes how to fix keytab file regeneration errors when using the same Kerberos service account and principal name.

 

C:\>ktpass -princ HTTP/fpx.fortilab.local@fortilab.local -mapuser fpx -pass <password> -crypto all -ptype KRB5_NT_PRINCIPAL -out fpx.keytab
Targeting domain controller: DC.fortilab.local
Failed to retrieve values for property ?????????: 0x10.
Failed to set property 'servicePrincipalName' to 'HTTP/fpx.fortilab.local' on Dn 'CN=FPX,CN=Users,DC=fortilab,DC=local': 0x32.
WARNING: Unable to set SPN mapping data.
If FPX already has an SPN mapping installed for HTTP/fpx.fortilab.local, this is no cause for concern.
Failed to retrieve user info for FPX: 0x5.
Aborted.

Scope FortiProxy.
Solution

The following is a procedure for regenerating Kerberos SPNs keytab keys.

 

Environment:

  • Domain: fortilab.local.
  • Host: fpx.fortilab.local.
  • Kerberos Service Account: fpx.
  • Service Principal: HTTP/fpx.fortilab.local@fortilab.local.

 

  1. Verify existing SPN.

Check which SPN is currently registered for the service account.

 

C:\>setspn -L fpx
Registered ServicePrincipalNames for CN=FPX,CN=Users,DC=fortilab,DC=local:
HTTP/fpx.fortilab.local

 

  1. Remove the existing SPN.

Unregister the SPN before recreating the keytab.

 

C:\>setspn -D HTTP/fpx.fortilab.local@fortilab.local fpx
Unregistering ServicePrincipalNames for CN=FPX,CN=Users,DC=fortilab,DC=local
HTTP/fpx.fortilab.local@fortilab.local
Updated object

 

  1. Generate a new keytab.

Create a new Kerberos keytab mapped to the service account.

 

C:\>ktpass -princ HTTP/fpx.fortilab.local@fortilab.local -mapuser fpx -pass <password> -crypto all -ptype KRB5_NT_PRINCIPAL -out fpx.keytab
Targeting domain controller: winsvr16.fortilab.local
Successfully mapped HTTP/fpx.fortilab.local to FPX.
Password successfully set!
Key created.
Key created.
Key created.
Key created.
Key created.
Output keytab to fpx.keytab:
Keytab version: 0x502
keysize 65 HTTP/fpx.fortilab.local@fortilab.local ptype 1 (KRB5_NT_PRINCIPAL) vno 8 etype 0x1 (DES-CBC-CRC) keylength 8 (0xd3fb58b607491c7a)
keysize 65 HTTP/fpx.fortilab.local@fortilab.local ptype 1 (KRB5_NT_PRINCIPAL) vno 8 etype 0x3 (DES-CBC-MD5) keylength 8 (0xd3fb58b607491c7a)
keysize 73 HTTP/fpx.fortilab.local@fortilab.local ptype 1 (KRB5_NT_PRINCIPAL) vno 8 etype 0x17 (RC4-HMAC) keylength 16 (0x5fbc3d5fec8206a30f4b6c473d68ae76)
keysize 89 HTTP/fpx.fortilab.local@fortilab.local ptype 1 (KRB5_NT_PRINCIPAL) vno 8 etype 0x12 (AES256-SHA1) keylength 32 (0x790940a03ceb0276aaaaeac72bf1b83cef20d7a000433f9ed6f224c3be57d6c8)
keysize 73 HTTP/fpx.fortilab.local@fortilab.local ptype 1 (KRB5_NT_PRINCIPAL) vno 8 etype 0x11 (AES128-SHA1) keylength 16 (0x5ccbd0bfc4c736a2d55e150862d55f71)

 

  1. Convert the keytab to Base64.

FortiProxy requires the keytab to be pasted in Base64 format.


C:\>certutil -encode fpx.keytab tmp.b64 && findstr /v /c:- tmp.b64 > fpx.txt
Input Length = 387
Output Length = 590
CertUtil: -encode command completed successfully.

 

  1. Remove whitespace and line breaks.

Using Notepad++.

 

Open the Replace dialog (press Ctrl + H).
Select Regular Expression.
In the 'Find what:' box, enter \h*\R.
\h* matches any horizontal whitespace characters (spaces, tabs).
\R matches any newline sequence (e.g., \r\n, \n).
Keep the replace box empty.
Select Replace All.

 

  1. Update Keytab in FortiProxy.

Update the encoded Keytab string in the FortiProxy configuration.

 

config user krb-keytab
    edit "keytab1"
        set principal "HTTP/fpx.fortilab.local@fortilab.local"
        set ldap-server "Adserver"
        set keytab "ENC <BASE64_KEYTAB>"
    next
end

 

Related articles:

Technical Tip: Configuring FortiProxy Kerberos authentication for explicit proxy

Technical Tip: How to debug Kerberos authentication in FortiProxy

    Thought Leadership Security Summit. Outpace New Threats with AI - enhanced defense. Tuesday, Septmeber 15, 8:30 AM - 2:30 PM PT. The Golf Club at Newcastle, WA.
    Virtual event | September 2026. SASE summit. The age of autonomous trust. Register here!