17f2fe78bSCy Schubert Building & Running Kerberos 5 on Windows 27f2fe78bSCy Schubert ---------------------------------------- 37f2fe78bSCy Schubert 47f2fe78bSCy SchubertThis file documents how to build MIT Kerberos for Windows. 57f2fe78bSCy SchubertThe MIT Kerberos for Windows distribution contains additional components 67f2fe78bSCy Schubertnot present in the Unix krb5 distribution, most notably the 77f2fe78bSCy SchubertMIT Kerberos Ticket Manager application. 87f2fe78bSCy Schubert 97f2fe78bSCy SchubertTo build Kerberos 5 on Windows, you will need the following: 107f2fe78bSCy Schubert 117f2fe78bSCy Schubert* A version of Visual Studio (at least 2013) which includes the 127f2fe78bSCy Schubert Microsoft Foundation Classes libraries. These instructions will 13*f1c4c3daSCy Schubert work for Visual Studio 2022 Community or Professional. Include 14*f1c4c3daSCy Schubert the following components: 157f2fe78bSCy Schubert 16*f1c4c3daSCy Schubert - Under Workloads, select Desktop development with C++ 17*f1c4c3daSCy Schubert - Under Individual components -> SDKs, libraries, and frameworks, 18*f1c4c3daSCy Schubert select "C++ MFC for latest v*** build tools (x86 & x64)". This 19*f1c4c3daSCy Schubert component is not required if you do not wish to build the 20*f1c4c3daSCy Schubert graphical ticket manager. 21*f1c4c3daSCy Schubert - Under Individual components -> Compilers, build tools, and 22*f1c4c3daSCy Schubert runtimes, select "C++ 20** Redistributable MSMs". This component 23*f1c4c3daSCy Schubert is not required if you do not wish to build the installer. 24*f1c4c3daSCy Schubert 25*f1c4c3daSCy Schubert* An OpenSSL installation, including the headers, DLLs, and import 26*f1c4c3daSCy Schubert .LIB files. This dependency is optional if you are not building 27*f1c4c3daSCy Schubert PKINIT. We recommend building OpenSSL from source code. 28*f1c4c3daSCy Schubert 29*f1c4c3daSCy Schubert* A version of Perl. We recommend Strawberry Perl as it will work 30*f1c4c3daSCy Schubert to build OpenSSL. 317f2fe78bSCy Schubert 327f2fe78bSCy Schubert* Some common Unix utilities such as sed/awk/cp/cat installed in the 337f2fe78bSCy Schubert command-line path. 347f2fe78bSCy Schubert 357f2fe78bSCy Schubert* To build an MSI installer, the Windows Installer XML (WiX) toolkit, 367f2fe78bSCy Schubert and to ensure that the HTML Help Compiler (hhc.exe) and the WiX 377f2fe78bSCy Schubert tools are in your command-line path. WiX version 3.11.1 is verified 387f2fe78bSCy Schubert to work with this codebase. 397f2fe78bSCy Schubert 407f2fe78bSCy SchubertA simple way to get the necessary Unix utilities is to install Git 417f2fe78bSCy SchubertBASH from https://gitforwindows.org and configure it to add the Unix 42*f1c4c3daSCy Schubertutilities to the command-line path. 437f2fe78bSCy Schubert 44*f1c4c3daSCy SchubertGit BASH contains a version of Perl, which will work to build krb5, 45*f1c4c3daSCy Schubertbut not to build OpenSSL from source. If both Git BASH and Strawberry 46*f1c4c3daSCy SchubertPerl are installed, you may need to adjust the command line path to 47*f1c4c3daSCy Schubertensure that the preferred Perl appears first when building OpenSSL. 487f2fe78bSCy Schubert 497f2fe78bSCy SchubertThe krb5 source tree may be obtained either directly on the Windows 507f2fe78bSCy Schubertmachine with a native git client cloning the krb5 public mirror at 517f2fe78bSCy Schuberthttps://github.com/krb5/krb5.git or on a separate (Unix) machine and 527f2fe78bSCy Schubertcopied over, such as from a VM host onto a Windows VM. If you are 537f2fe78bSCy Schubertchecking out the sources with git and are using the Git BASH Perl, 547f2fe78bSCy Schubertmake sure to set git's core.autocrlf variable to "input" or "false" to 557f2fe78bSCy Schubertavoid translating newlines. 567f2fe78bSCy Schubert 57*f1c4c3daSCy SchubertAfter Visual Studio is installed, you should be able to invoke command 58*f1c4c3daSCy Schubertprompts via the start menu (Visual Studio 2017 -> x64 Native Tools 59*f1c4c3daSCy SchubertCommand Prompt). 607f2fe78bSCy Schubert 617f2fe78bSCy SchubertIMPORTANT NOTE: By default, the sources are built with debug 627f2fe78bSCy Schubertinformation and linked against the debug version of the Microsoft C 637f2fe78bSCy SchubertRuntime library, which is not found on most Windows systems unless 647f2fe78bSCy Schubertthey have development tools, and requires a separate license to 657f2fe78bSCy Schubertdistribute. To build a release version, you need to define NODEBUG 667f2fe78bSCy Schuberteither in the environment or the nmake command-line. Debug 677f2fe78bSCy Schubertinformation in the compiled binaries and libraries may be retained by 687f2fe78bSCy Schubertdefining DEBUG_SYMBOL in the environment or on the nmake command line. 697f2fe78bSCy Schubert 707f2fe78bSCy Schubert 717f2fe78bSCy SchubertBuilding the code and installer: 727f2fe78bSCy Schubert------------------------------- 737f2fe78bSCy Schubert 747f2fe78bSCy SchubertFirst, make sure you have sed, (g)awk, cat, and cp. 757f2fe78bSCy SchubertYou must also define KRB_INSTALL_DIR either in the environment or 767f2fe78bSCy Schuberton the command line (for nmake install). If you are proceeding to build 777f2fe78bSCy Schubertthe MSI installer, this directory should be a temporary staging area in or 787f2fe78bSCy Schubertnear your build tree. The directory must exist before nmake install 79*f1c4c3daSCy Schubertis run. 80*f1c4c3daSCy Schubert 81*f1c4c3daSCy SchubertSet the environment variable OPENSSL_DIR to point to the root of the 82*f1c4c3daSCy SchubertOpenSSL install tree, and the environment variable OPENSSL_VERSION to 83*f1c4c3daSCy Schubertthe version string as it apears in the DLL names (such as "1_1" or 84*f1c4c3daSCy Schubert"3"). Include files should be in %OPENSSL_DIR%\include, import .LIB 85*f1c4c3daSCy Schubertfiles should be in %OPENSSL_DIR%\lib, and the libcrypto DLL should be 86*f1c4c3daSCy Schubertin %OPENSSL_DIR%\bin\libcrypto-%OPENSSL_VERSION%-x64.dll. These steps 87*f1c4c3daSCy Schubertare optional if you do not wish to build PKINIT. 887f2fe78bSCy Schubert 897f2fe78bSCy SchubertTo skip building the graphical ticket manager, run "set NO_LEASH=1" 90*f1c4c3daSCy Schubertbefore building, and do not build the installer. 917f2fe78bSCy Schubert 92*f1c4c3daSCy SchubertRun the following commands in a Visual Studio command prompt: 937f2fe78bSCy Schubert 94*f1c4c3daSCy Schubert 1) set PATH=%PATH%;"%WindowsSdkVerBinPath%"\x86 # To get uicc.exe 95*f1c4c3daSCy Schubert 2) set KRB_INSTALL_DIR=\path\to\dir # Where bin/include/lib lives 96*f1c4c3daSCy Schubert 3) set OPENSSL_DIR=\path\to\openssl # Where OpenSSL lives 97*f1c4c3daSCy Schubert 4) set OPENSSL_VERSION=3 # Version of OpenSSL DLLs 98*f1c4c3daSCy Schubert 5) cd xxx\src # Go to where source lives 99*f1c4c3daSCy Schubert 6) nmake -f Makefile.in prep-windows # Create Makefile for Windows 100*f1c4c3daSCy Schubert 7) nmake [NODEBUG=1] # Build the sources 101*f1c4c3daSCy Schubert 8) nmake install [NODEBUG=1] # Copy libraries/executables 102*f1c4c3daSCy Schubert 9) cd windows\installer\wix # Go to the installer source 103*f1c4c3daSCy Schubert10) nmake [NODEBUG=1] # Build the installer 1047f2fe78bSCy Schubert 105*f1c4c3daSCy SchubertStep 1 may be skipped if uicc is already in the command-line path (try 1067f2fe78bSCy Schubertrunning "uicc" to see if you get a usage message or a not-found 1077f2fe78bSCy Schuberterror), or if you are not building the graphical ticket manager. 1087f2fe78bSCy Schubert 1097f2fe78bSCy Schubert 1107f2fe78bSCy SchubertRunning Kerberos 5 Apps: 1117f2fe78bSCy Schubert----------------------- 1127f2fe78bSCy Schubert 1137f2fe78bSCy SchubertMake sure you have a valid krb5.ini file. 1147f2fe78bSCy SchubertBy default, an empty krb5.ini is installed in CSIDL_COMMON_APPDATA 1157f2fe78bSCy Schubert(that is, %SystemDrive%\ProgramData\MIT\Kerberos5\ on newer-than-XP). 1167f2fe78bSCy Schubert(ProgramData is a hidden folder.) You may need to customize it with 1177f2fe78bSCy Schubertsettings for your site, but since DNS lookups are enabled for locating 1187f2fe78bSCy SchubertKDCs, many sites will not need further customization. The file format is 1197f2fe78bSCy Schubertidentical to that of a Unix krb5.conf file. 1207f2fe78bSCy Schubert 1217f2fe78bSCy Schubert 1227f2fe78bSCy Schubertkrb5.ini File: 1237f2fe78bSCy Schubert------------- 1247f2fe78bSCy Schubert 1257f2fe78bSCy SchubertWARNING: Despite its name, this is not a Windows .ini file. 1267f2fe78bSCy SchubertTherefore, do not try to use any .ini tools, including the Windows API 1277f2fe78bSCy Schubertor any installer tools to manipulate this file. Its format is subtly 1287f2fe78bSCy Schubertdifferent from Windows .ini files! 1297f2fe78bSCy Schubert 1307f2fe78bSCy Schubert 1317f2fe78bSCy SchubertControlling the Kerberos 5 Run-Time Environment: 1327f2fe78bSCy Schubert----------------------------------------------- 1337f2fe78bSCy Schubert 1347f2fe78bSCy SchubertThe Kerberos 5 configuration file and credentials cache can be 1357f2fe78bSCy Schubertcontrolled with environment variables and registry settings. The 1367f2fe78bSCy Schubertenvironment variable for a particular setting always takes precedence. 1377f2fe78bSCy SchubertNext in precedence comes the setting in the registry under 1387f2fe78bSCy SchubertHKEY_CURRENT_USER\Software\MIT\Kerberos5. Then comes the registry 1397f2fe78bSCy Schubertsetting under HKEY_LOCAL_MACHINE\Software\MIT\Kerberos5. If none of 1407f2fe78bSCy Schubertthose are found, a default value is used. 1417f2fe78bSCy Schubert 1427f2fe78bSCy SchubertConfiguration File: 1437f2fe78bSCy Schubert- Environment: KRB5_CONFIG 1447f2fe78bSCy Schubert- Registry Value: config 1457f2fe78bSCy Schubert- Default: looks in the user's AppData directory, the machine's ProgramData 1467f2fe78bSCy Schubert directory, krb5_32.dll's dir and Windows directory 1477f2fe78bSCy Schubert 1487f2fe78bSCy SchubertDefault Credentials Cache: 1497f2fe78bSCy Schubert- Environment: KRB5CCNAME 1507f2fe78bSCy Schubert- Registry Value: ccname 1517f2fe78bSCy Schubert- Default: API: 1527f2fe78bSCy Schubert 1537f2fe78bSCy Schubert 1547f2fe78bSCy SchubertCredentials Cache: 1557f2fe78bSCy Schubert----------------- 1567f2fe78bSCy Schubert 1577f2fe78bSCy SchubertIn addition to standard FILE: (disk file) and MEMORY: (in-process 1587f2fe78bSCy Schubertnon-shared memory) Windows supports the API: cache type, which is a 1597f2fe78bSCy Schubertshared memory cache. Kerberos for Windows also has access to an 1607f2fe78bSCy SchubertMSLSA: cache type, which directly accesses the Microsoft Kerberos 1617f2fe78bSCy SchubertLogon Session credentials cache. The MSLSA: cache is available when the 1627f2fe78bSCy Schubertuser logon is performed using Kerberos either to an Active Directory Domain 1637f2fe78bSCy Schubertor a non-Microsoft KDC; the ms2mit and mit2ms utilities can also be used 1647f2fe78bSCy Schubertto interact with it, though there are some limitations. 1657f2fe78bSCy Schubert 1667f2fe78bSCy SchubertA user is able to logon to Windows using the Kerberos LSA if the machine 1677f2fe78bSCy Schubertis part of a Windows Active Directory domain or if the machine has been 1687f2fe78bSCy Schubertconfigured to authenticate to a non-Microsoft KDC such as MIT. 1697f2fe78bSCy SchubertThe instructions for configuring a Windows 2000 XP workstation to 1707f2fe78bSCy Schubertauthenticate to a non-Microsoft KDC are documented in TechNet somewhere. 1717f2fe78bSCy SchubertIn brief: 1727f2fe78bSCy Schubert 1737f2fe78bSCy Schubert 1. Install the Windows support tools in order to obtain KSETUP.EXE 1747f2fe78bSCy Schubert and KTPASS.EXE. 1757f2fe78bSCy Schubert 2. Install the Windows Resource Kit to obtain KERBTRAY.EXE and KLIST.EXE 1767f2fe78bSCy Schubert 3. Add Realms and associated KDCs with: *KSETUP /AddKdc <realm> 1777f2fe78bSCy Schubert [<kdcname>]*. If you leave off the <kdcname> DNS SRV records will 1787f2fe78bSCy Schubert be used. 1797f2fe78bSCy Schubert 4. Specify the password change service host for the realm with: 1807f2fe78bSCy Schubert *KSETUP /AddKpasswd <realm> <Kpwdhost>* 1817f2fe78bSCy Schubert 5. Assign the realm of the local machine with: *KSETUP /SetRealm 1827f2fe78bSCy Schubert <realm>* where realm must be all upper case. 1837f2fe78bSCy Schubert 6. Assign the local machine's password with: *KSETUP 1847f2fe78bSCy Schubert /SetComputerPassword <Password> 1857f2fe78bSCy Schubert * 1867f2fe78bSCy Schubert 7. Specify the capabilities of the Realm KDC with: *KSETUP 1877f2fe78bSCy Schubert /SetRealmFlags <realm> <flag> [<flag> ...]* where flags may be 1887f2fe78bSCy Schubert *None, SendAddress, TcpSupported, Delegate, *and *NcSupported*, 1897f2fe78bSCy Schubert 8. Map principal names to local accounts with: *KSETUP /MapUser 1907f2fe78bSCy Schubert <principal> <account>* 1917f2fe78bSCy Schubert 1927f2fe78bSCy SchubertOn the MIT KDC, you must then create service principals using the "Password" 1937f2fe78bSCy Schubertassigned to the machine. So far the minimum list of principals required appear 1947f2fe78bSCy Schubertto be for a machine named "mymachine" in the realm "EXAMPLE.COM" with a 1957f2fe78bSCy Schubertdomain name of "example.com": 1967f2fe78bSCy Schubert 1977f2fe78bSCy Schubert * host/mymachine@EXAMPLE.COM 1987f2fe78bSCy Schubert * host/mymachine.example.com@EXAMPLE.COM 1997f2fe78bSCy Schubert * cifs/mymachine@EXAMPLE.COM 2007f2fe78bSCy Schubert * cifs/mymachine.example.com@EXAMPLE.COM 2017f2fe78bSCy Schubert 2027f2fe78bSCy SchubertThere may very well be other services for which principals must be created depending 2037f2fe78bSCy Schuberton what services are being executed on the machine. 2047f2fe78bSCy Schubert 2057f2fe78bSCy SchubertIt is very important to note that while you can successfully log into a Windows 2067f2fe78bSCy Schubertworkstation by authenticating to the KDC without creating a host key; the logon 2077f2fe78bSCy Schubertsession you receive will not be a Kerberos Logon Session. There will be no Kerberos 2087f2fe78bSCy Schubertprincipal and no LSA cache to access. 2097f2fe78bSCy Schubert 2107f2fe78bSCy SchubertThe result of a real KSETUP configuration looks like this: 2117f2fe78bSCy Schubert 2127f2fe78bSCy Schubert [C:\4\4NT]ksetup 2137f2fe78bSCy Schubert default realm = KRB5.COLUMBIA.EDU (external) 2147f2fe78bSCy Schubert ATHENA.MIT.EDU: 2157f2fe78bSCy Schubert kdc = kerberos.mit.edu 2167f2fe78bSCy Schubert kdc = kerberos-1.mit.edu 2177f2fe78bSCy Schubert kdc = kerberos-2.mit.edu 2187f2fe78bSCy Schubert kdc = kerberos-3.mit.edu 2197f2fe78bSCy Schubert Realm Flags = 0x0 none 2207f2fe78bSCy Schubert CC.COLUMBIA.EDU: 2217f2fe78bSCy Schubert kdc = kerberos.cc.columbia.edu 2227f2fe78bSCy Schubert Realm Flags = 0x0 none 2237f2fe78bSCy Schubert GRAND.CENTRAL.ORG: 2247f2fe78bSCy Schubert kdc = penn.central.org 2257f2fe78bSCy Schubert kdc = grand-opening.mit.edu 2267f2fe78bSCy Schubert Realm Flags = 0x0 none 2277f2fe78bSCy Schubert KRB5.COLUMBIA.EDU: 2287f2fe78bSCy Schubert kdc = yclept.kermit.columbia.edu 2297f2fe78bSCy Schubert Realm Flags = 0x0 none 2307f2fe78bSCy Schubert OPENAFS.ORG: 2317f2fe78bSCy Schubert kdc = virtue.openafs.org 2327f2fe78bSCy Schubert Realm Flags = 0x0 none 2337f2fe78bSCy Schubert Mapping jaltman@KRB5.COLUMBIA.EDU to jaltman. 2347f2fe78bSCy Schubert Mapping jaltman@CC.COLUMBIA.EDU to jaltman. 2357f2fe78bSCy Schubert Mapping jaltman@ATHENA.MIT.EDU to jaltman. 2367f2fe78bSCy Schubert Mapping all users (*) to a local account by the same name (*). 2377f2fe78bSCy Schubert 2387f2fe78bSCy SchubertThe MSLSA: credential cache relies on the ability to extract the entire 2397f2fe78bSCy SchubertKerberos ticket including the session key from the Kerberos LSA. In an 2407f2fe78bSCy Schubertattempt to increase security Microsoft has begun to implement a feature 2417f2fe78bSCy Schubertby which they no longer export the session keys for Ticket Getting Tickets. 2427f2fe78bSCy SchubertThis has the side effect of making them useless to the MIT krb5 library 2437f2fe78bSCy Schubertwhen attempting to request additional service tickets. 2447f2fe78bSCy Schubert 2457f2fe78bSCy SchubertThis new feature has been seen in Windows 2003 Server, Windows 2000 Server SP4, 2467f2fe78bSCy Schubertand Windows XP SP2. We assume that it will be implemented in all future 2477f2fe78bSCy SchubertMicrosoft operating systems supporting the Kerberos SSPI. Microsoft does work 2487f2fe78bSCy Schubertclosely with MIT and has provided a registry key to disable this new feature. 2497f2fe78bSCy SchubertOn server platforms the key is specified as: 2507f2fe78bSCy Schubert 2517f2fe78bSCy Schubert HKLM\SYSTEM\CurrentControlSet\Control\Lsa\Kerberos\Parameters 2527f2fe78bSCy Schubert AllowTGTSessionKey = 0x01 (DWORD) 2537f2fe78bSCy Schubert 2547f2fe78bSCy SchubertOn workstation platforms the key is specified as: 2557f2fe78bSCy Schubert 2567f2fe78bSCy Schubert HKLM\SYSTEM\CurrentControlSet\Control\Lsa\Kerberos 2577f2fe78bSCy Schubert AllowTGTSessionKey = 0x01 (DWORD) 2587f2fe78bSCy Schubert 2597f2fe78bSCy SchubertThe Kerberos for Windows installer automatically sets this key on installation 2607f2fe78bSCy Schubertand unsets it on uninstall, allowing the MSLSA: cache type to be used. 2617f2fe78bSCy Schubert 2627f2fe78bSCy SchubertIt has been noted that the Microsoft Kerberos LSA does not provide enough 2637f2fe78bSCy Schubertinformation within its KERB_EXTERNAL_TICKET structure to properly construct 2647f2fe78bSCy Schubertthe Client Principal simply by examining a single ticket. From the MSDN 2657f2fe78bSCy SchubertLibrary: 2667f2fe78bSCy Schubert 2677f2fe78bSCy Schubert ClientName 2687f2fe78bSCy Schubert KERB_EXTERNAL_NAME structure that contains the client name in the ticket. 2697f2fe78bSCy Schubert This name is relative to the current domain. 2707f2fe78bSCy Schubert 2717f2fe78bSCy Schubert DomainName 2727f2fe78bSCy Schubert UNICODE_STRING that contains the name of the domain that corresponds to 2737f2fe78bSCy Schubert the ServiceName member. This is the domain that issued the ticket. 2747f2fe78bSCy Schubert 2757f2fe78bSCy Schubert TargetDomainName 2767f2fe78bSCy Schubert UNICODE_STRING that contains the name of the domain in which the ticket is 2777f2fe78bSCy Schubert valid. For an interdomain ticket, this is the destination domain. 2787f2fe78bSCy Schubert 2797f2fe78bSCy Schubert AltTargetDomainName 2807f2fe78bSCy Schubert UNICODE_STRING that contains a synonym for the destination domain. Every 2817f2fe78bSCy Schubert domain has two names: a DNS name and a NetBIOS name. If the name returned 2827f2fe78bSCy Schubert in the ticket is different from the name used to request the ticket (the 2837f2fe78bSCy Schubert Kerberos Key Distribution Center (KDC) may do name mapping), this string 2847f2fe78bSCy Schubert contains the original name. 2857f2fe78bSCy Schubert 2867f2fe78bSCy SchubertUnfortunately, there is no field here which contains the domain of the client. 2877f2fe78bSCy SchubertIn order for the krb5_ccache to properly report the client principal name, the 2887f2fe78bSCy Schubertclient principal name is constructed by utilizing the ClientName and DomainName 2897f2fe78bSCy Schubertfields of the Initial TGT associated with the Kerberos LSA credential cache. 2907f2fe78bSCy SchubertTo disable the use of the TGT info and instead simply use the "DomainName" field 2917f2fe78bSCy Schubertof the current ticket define one of the following registry keys depending on 2927f2fe78bSCy Schubertwhether the change should be system global or just for the current user. 2937f2fe78bSCy Schubert 2947f2fe78bSCy Schubert HKLM\Software\MIT\Kerberos5\ 2957f2fe78bSCy Schubert PreserveInitialTicketIdentity = 0x0 (DWORD) 2967f2fe78bSCy Schubert 2977f2fe78bSCy Schubert HKCU\Software\MIT\Kerberos5\ 2987f2fe78bSCy Schubert PreserveInitialTicketIdentity = 0x0 (DWORD) 2997f2fe78bSCy Schubert 3007f2fe78bSCy SchubertGSSAPI Sample Client: 3017f2fe78bSCy Schubert--------------------- 3027f2fe78bSCy Schubert 3037f2fe78bSCy SchubertThe GSS API Sample Client provided in this distribution is compatible with the 3047f2fe78bSCy Schubertgss-server application built on Unix/Linux systems. This client is not compatible 3057f2fe78bSCy Schubertwith the Platform SDK/Samples/Security/SSPI/GSS/ samples which Microsoft has been 3067f2fe78bSCy Schubertshipping as of January 2004. Revised versions of these samples are available upon 3077f2fe78bSCy Schubertrequest to krbdev@mit.edu. 3087f2fe78bSCy Schubert 3097f2fe78bSCy SchubertMore Information: 3107f2fe78bSCy Schubert---------------- 3117f2fe78bSCy Schubert 3127f2fe78bSCy SchubertFor more information, please read the Kerberos 5 documentation in 3137f2fe78bSCy Schubertthe doc directory of the distribution. 314