Windows: Script for generating exports lists for shim layer
[heimdal.git] / doc / setup.texi
blob97e5975331afb1e8db13aa6410a64d984421e981
1 @c $Id$
3 @node Setting up a realm, Applications, Building and Installing, Top
5 @chapter Setting up a realm
8 @cindex realm
9 realm is an administrative domain.  The name of a Kerberos realm is
10 usually the Internet domain name in uppercase.  Call your realm the same
11 as your Internet domain name if you do not have strong reasons for not
12 doing so.  It will make life easier for you and everyone else.
14 @menu
15 * Configuration file::
16 * Creating the database::
17 * Modifying the database::
18 * Checking the setup::
19 * keytabs::
20 * Serving Kerberos 4/524/kaserver::
21 * Remote administration::
22 * Password changing::
23 * Testing clients and servers::
24 * Slave Servers::
25 * Incremental propagation::
26 * Encryption types and salting::
27 * Cross realm::
28 * Transit policy::
29 * Setting up DNS::
30 * Using LDAP to store the database::
31 * Providing Kerberos credentials to servers and programs::
32 * Setting up PK-INIT::
33 * Debugging Kerberos problems::
34 @end menu
36 @node  Configuration file, Creating the database, Setting up a realm, Setting up a realm
37 @section Configuration file
39 To setup a realm you will first have to create a configuration file:
40 @file{/etc/krb5.conf}. The @file{krb5.conf} file can contain many
41 configuration options, some of which are described here.
43 There is a sample @file{krb5.conf} supplied with the distribution.
45 The configuration file is a hierarchical structure consisting of
46 sections, each containing a list of bindings (either variable
47 assignments or subsections). A section starts with
48 @samp{[@samp{section-name}]}.  A binding consists of a left hand side, an equal sign
49 (@samp{=}) and a right hand side (the left hand side tag must be
50 separated from the equal sign with some whitespace). Subsections have a
51 @samp{@{} as the first non-whitespace character after the equal sign. All
52 other bindings are treated as variable assignments. The value of a
53 variable extends to the end of the line.
55 @example
56 [section1]
57         a-subsection = @{
58                 var = value1
59                 other-var = value with @{@}
60                 sub-sub-section = @{
61                         var = 123
62                 @}
63         @}
64         var = some other value
65 [section2]
66         var = yet another value
67 @end example
69 In this manual, names of sections and bindings will be given as strings
70 separated by slashes (@samp{/}). The @samp{other-var} variable will thus
71 be @samp{section1/a-subsection/other-var}.
73 For in-depth information about the contents of the configuration file, refer to
74 the @file{krb5.conf} manual page. Some of the more important sections
75 are briefly described here.
77 The @samp{libdefaults} section contains a list of library configuration
78 parameters, such as the default realm and the timeout for KDC
79 responses. The @samp{realms} section contains information about specific
80 realms, such as where they hide their KDC@. This section serves the same
81 purpose as the Kerberos 4 @file{krb.conf} file, but can contain more
82 information. Finally the @samp{domain_realm} section contains a list of
83 mappings from domains to realms, equivalent to the Kerberos 4
84 @file{krb.realms} file.
86 To continue with the realm setup, you will have to create a configuration file,
87 with contents similar to the following.
89 @example
90 [libdefaults]
91         default_realm = MY.REALM
92 [realms]
93         MY.REALM = @{
94                 kdc = my.kdc my.slave.kdc
95                 kdc = my.third.kdc
96                 kdc = 130.237.237.17
97                 kdc = [2001:6b0:1:ea::100]:88
98         @}
99 [domain_realm]
100         .my.domain = MY.REALM
102 @end example
104 If you use a realm name equal to your domain name, you can omit the
105 @samp{libdefaults}, and @samp{domain_realm}, sections. If you have a DNS
106 SRV-record for your realm, or your Kerberos server has DNS CNAME
107 @samp{kerberos.my.realm}, you can omit the @samp{realms} section too.
109 @node Creating the database, Modifying the database, Configuration file, Setting up a realm
110 @section Creating the database
112 The database library will look for the database in the directory
113 @file{@value{dbdir}}, so you should probably create that directory.
114 Make sure the directory has restrictive permissions.
116 @example
117 # mkdir /var/heimdal
118 @end example
120 The keys of all the principals are stored in the database.  If you
121 choose to, these can be encrypted with a master key.  You do not have to
122 remember this key (or password), but just to enter it once and it will
123 be stored in a file (@file{/var/heimdal/m-key}).  If you want to have a
124 master key, run @samp{kstash} to create this master key:
126 @example
127 # kstash
128 Master key:
129 Verifying password - Master key:
130 @end example
132 If you want to generate a random master key you can use the
133 @kbd{--random-key} flag to kstash. This will make sure you have a good key
134 on which attackers can't do a dictionary attack.
136 If you have a master key, make sure you make a backup of your master
137 key file; without it backups of the database are of no use.
139 To initialise the database use the @command{kadmin} program, with the
140 @kbd{-l} option (to enable local database mode). First issue a
141 @kbd{init MY.REALM} command. This will create the database and insert
142 default principals for that realm. You can have more than one realm in
143 one database, so @samp{init} does not destroy any old database.
145 Before creating the database, @samp{init} will ask you some questions
146 about maximum ticket lifetimes.
148 After creating the database you should probably add yourself to it. You
149 do this with the @samp{add} command. It takes as argument the name of a
150 principal. The principal should contain a realm, so if you haven't set up
151 a default realm, you will need to explicitly include the realm.
153 @example
154 # kadmin -l
155 kadmin> init MY.REALM
156 Realm max ticket life [unlimited]:
157 Realm max renewable ticket life [unlimited]:
158 kadmin> add me
159 Max ticket life [unlimited]:
160 Max renewable life [unlimited]:
161 Attributes []:
162 Password:
163 Verifying password - Password:
164 @end example
166 Now start the KDC and try getting a ticket.
168 @example
169 # kdc &
170 # kinit me
171 me@@MY.REALMS's Password:
172 # klist
173 Credentials cache: /tmp/krb5cc_0
174         Principal: me@@MY.REALM
176   Issued           Expires          Principal
177 Aug 25 07:25:55  Aug 25 17:25:55  krbtgt/MY.REALM@@MY.REALM
178 @end example
180 If you are curious you can use the @samp{dump} command to list all the
181 entries in the database.  It should look something similar to the
182 following example (note that the entries here are truncated for
183 typographical reasons):
185 @smallexample
186 kadmin> dump
187 me@@MY.REALM 1:0:1:0b01d3cb7c293b57:-:0:7:8aec316b9d1629e3baf8 ...
188 kadmin/admin@@MY.REALM 1:0:1:e5c8a2675b37a443:-:0:7:cb913ebf85 ...
189 krbtgt/MY.REALM@@MY.REALM 1:0:1:52b53b61c875ce16:-:0:7:c8943be ...
190 kadmin/changepw@@MY.REALM 1:0:1:f48c8af2b340e9fb:-:0:7:e3e6088 ...
191 @end smallexample
193 @node Modifying the database, Checking the setup, Creating the database, Setting up a realm
194 @section Modifying the database
196 All modifications of principals are done with with kadmin.
198 A principal has several attributes and lifetimes associated with it.
200 Principals are added, renamed, modified, and deleted with the kadmin
201 commands @samp{add}, @samp{rename}, @samp{modify}, @samp{delete}.
202 Both interactive editing and command line flags can be used (use --help
203 to list the available options).
205 There are different kinds of types for the fields in the database;
206 attributes, absolute time times and relative times.
208 @subsection Attributes
210 When doing interactive editing, attributes are listed with @samp{?}.
212 The attributes are given in a comma (@samp{,}) separated list.
213 Attributes are removed from the list by prefixing them with @samp{-}.
215 @smallexample
216 kadmin> modify me
217 Max ticket life [1 day]:
218 Max renewable life [1 week]:
219 Principal expiration time [never]:
220 Password expiration time [never]:
221 Attributes [disallow-renewable]: requires-pre-auth,-disallow-renewable
222 kadmin> get me
223             Principal: me@@MY.REALM
224 [...]
225            Attributes: requires-pre-auth
226 @end smallexample
228 @subsection Absolute times
230 The format for absolute times are any of the following:
232 @smallexample
233 never
235 YYYY-mm-dd
236 YYYY-mm-dd HH:MM:SS
237 @end smallexample
240 @subsection Relative times
242 The format for relative times are any of the following combined:
244 @smallexample
245 N year
246 M month
247 O day
248 P hour
249 Q minute
250 R second
251 @end smallexample
253 @c Describe more of kadmin commands here...
255 @node Checking the setup, keytabs, Modifying the database, Setting up a realm
256 @section Checking the setup
258 There are two tools that can check the consistency of the Kerberos
259 configuration file and the Kerberos database.
261 The Kerberos configuration file is checked using
262 @command{verify_krb5_conf}. The tool checks for common errors, but
263 commonly there are several uncommon configuration entries that are
264 never added to the tool and thus generates ``unknown entry'' warnings.
265 This is usually nothing to worry about.
267 The database check is built into the kadmin tool. It will check for
268 common configuration error that will cause problems later. Common
269 check are for existence and flags on important principals. The
270 database check by run by the following command :
272 @example
273 kadmin -l check REALM.EXAMPLE.ORG
274 @end example
276 @node keytabs, Serving Kerberos 4/524/kaserver, Checking the setup, Setting up a realm
277 @section keytabs
279 To extract a service ticket from the database and put it in a keytab, you
280 need to first create the principal in the database with @samp{add}
281 (using the @kbd{--random-key} flag to get a random key) and then
282 extract it with @samp{ext_keytab}.
284 @example
285 kadmin> add --random-key host/my.host.name
286 Max ticket life [unlimited]:
287 Max renewable life [unlimited]:
288 Attributes []:
289 kadmin> ext host/my.host.name
290 kadmin> exit
291 # ktutil list
292 Version  Type             Principal
293      1   des-cbc-md5      host/my.host.name@@MY.REALM
294      1   des-cbc-md4      host/my.host.name@@MY.REALM
295      1   des-cbc-crc      host/my.host.name@@MY.REALM
296      1   des3-cbc-sha1    host/my.host.name@@MY.REALM
297 @end example
299 @node Serving Kerberos 4/524/kaserver, Remote administration, keytabs, Setting up a realm
300 @section Serving Kerberos 4/524/kaserver
302 Heimdal can be configured to support 524, Kerberos 4 or kaserver. All
303 these services are turned off by default. Kerberos 4 is always
304 supported by the KDC, but the Kerberos 4 client support also depends
305 on Kerberos 4 support having been included at compile-time, using
306 @kbd{--with-krb4=dir}.
308 @subsection 524
310 524 is a service that allows the KDC to convert Kerberos 5 tickets to
311 Kerberos 4 tickets for backward compatibility. See also Using 2b
312 tokens with AFS in @xref{AFS}.
314 524 can be turned on by adding this to the configuration file
316 @example
317 [kdc]
318         enable-524 = yes
319 @end example
321 @subsection Kerberos 4
323 Kerberos 4 is the predecessor to to Kerberos 5. It only supports
324 single DES@. You should only enable Kerberos 4 support if you have
325 needs for compatibility with an installed base of Kerberos 4
326 clients/servers.
328 Kerberos 4 can be turned on by adding this to the configuration file
330 @example
331 [kdc]
332         enable-kerberos4 = yes
333 @end example
335 @subsection kaserver
337 Kaserver is a Kerberos 4 that is used in AFS@.  The protocol has some
338 extra features over plain Kerberos 4, but like Kerberos 4, only uses
339 single DES@.
341 You should only enable Kaserver support if you have needs for
342 compatibility with an installed base of AFS machines.
344 Kaserver can be turned on by adding this to the configuration file
346 @example
347 [kdc]
348         enable-kaserver = yes
349 @end example
351 @node Remote administration, Password changing, Serving Kerberos 4/524/kaserver, Setting up a realm
352 @section Remote administration
354 The administration server, @command{kadmind}, can be started by
355 @command{inetd} (which isn't recommended) or run as a normal daemon. If you
356 want to start it from @command{inetd} you should add a line similar to the
357 one below to your @file{/etc/inetd.conf}.
359 @example
360 kerberos-adm stream     tcp     nowait  root /usr/heimdal/libexec/kadmind kadmind
361 @end example
363 You might need to add @samp{kerberos-adm} to your @file{/etc/services}
364 as @samp{749/tcp}.
366 Access to the administration server is controlled by an ACL file,
367 (default @file{/var/heimdal/kadmind.acl}.) The file has the following
368 syntax:
369 @smallexample
370 principal       [priv1,priv2,...]       [glob-pattern]
371 @end smallexample
373 The matching is from top to bottom for matching principals (and if given,
374 glob-pattern).  When there is a match, the access rights of that line are
375 applied.
377 The privileges you can assign to a principal are: @samp{add},
378 @samp{change-password} (or @samp{cpw} for short), @samp{delete},
379 @samp{get}, @samp{list}, and @samp{modify}, or the special privilege
380 @samp{all}. All of these roughly correspond to the different commands
381 in @command{kadmin}.
383 If a @var{glob-pattern} is given on a line, it restricts the access
384 rights for the principal to only apply for subjects that match the
385 pattern.  The patterns are of the same type as those used in shell
386 globbing, see @url{none,,fnmatch(3)}.
388 In the example below @samp{lha/admin} can change every principal in the
389 database. @samp{jimmy/admin} can only modify principals that belong to
390 the realm @samp{E.KTH.SE}. @samp{mille/admin} is working at the
391 help desk, so he should only be able to change the passwords for single
392 component principals (ordinary users). He will not be able to change any
393 @samp{/admin} principal.
395 @example
396 lha/admin@@E.KTH.SE     all
397 jimmy/admin@@E.KTH.SE   all             *@@E.KTH.SE
398 jimmy/admin@@E.KTH.SE   all             */*@@E.KTH.SE
399 mille/admin@@E.KTH.SE   change-password *@@E.KTH.SE
400 @end example
402 @node Password changing, Testing clients and servers, Remote administration, Setting up a realm
403 @section Password changing
405 To allow users to change their passwords, you should run @command{kpasswdd}.
406 It is not run from @command{inetd}.
408 You might need to add @samp{kpasswd} to your @file{/etc/services} as
409 @samp{464/udp}.
411 @subsection Password quality assurance
413 It is important that users have good passwords, both to make it harder
414 to guess them and to avoid off-line attacks (although
415 pre-authentication provides some defence against off-line attacks).
416 To ensure that the users choose good passwords, you can enable
417 password quality controls in @command{kpasswdd} and @command{kadmind}.
418 The controls themselves are done in a shared library or an external
419 program that is used by @command{kpasswdd}.  To configure in these
420 controls, add lines similar to the following to your
421 @file{/etc/krb5.conf}:
423 @example
424 [password_quality]
425         policies = external-check builtin:minimum-length modulename:policyname
426         external_program = /bin/false
427         policy_libraries = @var{library1.so} @var{library2.so}
428 @end example
430 In @samp{[password_quality]policies} the module name is optional if
431 the policy name is unique in all modules (members of
432 @samp{policy_libraries}).  All built-in policies can be qualified with
433 a module name of @samp{builtin} to unambiguously specify the built-in
434 policy and not a policy by the same name from a loaded module.
436 The built-in policies are
438 @itemize @bullet
440 @item external-check
442 Executes the program specified by @samp{[password_quality]external_program}.
444 A number of key/value pairs are passed as input to the program, one per
445 line, ending with the string @samp{end}.  The key/value lines are of
446 the form
447 @example
448 principal: @var{principal}
449 new-password: @var{password}
450 @end example
451 where @var{password} is the password to check for the previous
452 @var{principal}.
454 If the external application approves the password, it should return
455 @samp{APPROVED} on standard out and exit with exit code 0.  If it
456 doesn't approve the password, an one line error message explaining the
457 problem should be returned on standard error and the application
458 should exit with exit code 0.  In case of a fatal error, the
459 application should, if possible, print an error message on standard
460 error and exit with a non-zero error code.
462 @item minimum-length
464 The minimum length password quality check reads the configuration file
465 stanza @samp{[password_quality]min_length} and requires the password
466 to be at least this length.
468 @item character-class
470 The character-class password quality check reads the configuration
471 file stanza @samp{[password_quality]min_classes}. The policy requires
472 the password to have characters from at least that many character
473 classes. Default value if not given is 3.
475 The four different characters classes are, uppercase, lowercase,
476 number, special characters.
478 @end itemize
480 If you want to write your own shared object to check password
481 policies, see the manual page @manpage{kadm5_pwcheck,3}.
483 Code for a password quality checking function that uses the cracklib
484 library can be found in @file{lib/kadm5/sample_password_check.c} in
485 the source code distribution.  It requires that the cracklib library
486 be built with the patch available at
487 @url{ftp://ftp.pdc.kth.se/pub/krb/src/cracklib.patch}.
489 A sample policy external program is included in
490 @file{lib/kadm5/check-cracklib.pl}.
492 If no password quality checking function is configured, the only check
493 performed is that the password is at least six characters long.
495 To check the password policy settings, use the command
496 @command{verify-password-quality} in @command{kadmin} program. The password
497 verification is only performed locally, on the client.  It may be
498 convenient to set the environment variable @samp{KRB5_CONFIG} to point
499 to a test version of @file{krb5.conf} while you're testing the
500 @samp{[password_quality]} stanza that way.
502 @node Testing clients and servers, Slave Servers, Password changing, Setting up a realm
503 @section Testing clients and servers
505 Now you should be able to run all the clients and servers.  Refer to the
506 appropriate man pages for information on how to use them.
508 @node Slave Servers, Incremental propagation, Testing clients and servers, Setting up a realm
509 @section Slave servers, Incremental propagation, Testing clients and servers, Setting up a realm
511 It is desirable to have at least one backup (slave) server in case the
512 master server fails. It is possible to have any number of such slave
513 servers but more than three usually doesn't buy much more redundancy.
515 All Kerberos servers for a realm must have the same database so that
516 they present the same service to the users.  The
517 @pindex hprop
518 @command{hprop} program, running on the master, will propagate the database
519 to the slaves, running
520 @pindex hpropd
521 @command{hpropd} processes.
523 Every slave needs a database directory, the master key (if it was used
524 for the database) and a keytab with the principal
525 @samp{hprop/@var{hostname}}.  Add the principal with the
526 @pindex ktutil
527 @command{ktutil} command and start
528 @pindex hpropd
529 @command{hpropd}, as follows:
531 @example
532 slave# ktutil get -p foo/admin hprop/`hostname`
533 slave# mkdir /var/heimdal
534 slave# hpropd
535 @end example
537 The master will use the principal @samp{kadmin/hprop} to authenticate to
538 the slaves.  This principal should be added when running @kbd{kadmin -l
539 init} but if you do not have it in your database for whatever reason,
540 please add it with @kbd{kadmin -l add}.
542 Then run
543 @pindex hprop
544 @code{hprop} on the master:
546 @example
547 master# hprop slave
548 @end example
550 This was just an hands-on example to make sure that everything was
551 working properly.  Doing it manually is of course the wrong way, and to
552 automate this you will want to start
553 @pindex hpropd
554 @command{hpropd} from @command{inetd} on the slave(s) and regularly run
555 @pindex hprop
556 @command{hprop} on the master to regularly propagate the database.
557 Starting the propagation once an hour from @command{cron} is probably a
558 good idea.
560 @node Incremental propagation, Encryption types and salting, Slave Servers, Setting up a realm
561 @section Incremental propagation
563 There is also a newer mechanism for
564 doing incremental propagation in Heimdal.  Instead of sending the whole
565 database regularly, it sends the changes as they happen on the master to
566 the slaves.  The master keeps track of all the changes by assigning a
567 version number to every change to the database.  The slaves know which
568 was the latest version they saw and in this way it can be determined if
569 they are in sync or not.  A log of all the changes is kept on the master,
570 and when a slave is at an older version than the oldest one in the
571 log, the whole database has to be sent.
573 Protocol-wise, all the slaves connect to the master and as a greeting
574 tell it the latest version that they have (@samp{IHAVE} message).  The
575 master then responds by sending all the changes between that version and
576 the current version at the master (a series of @samp{FORYOU} messages)
577 or the whole database in a @samp{TELLYOUEVERYTHING} message.  There is
578 also a keep-alive protocol that makes sure all slaves are up and running.
580 In addition on listening on the network to get connection from new
581 slaves, the ipropd-master also listens on a status unix
582 socket. kadmind and kpasswdd both open that socket when a transation
583 is done and written a notification to the socket. That cause
584 ipropd-master to check for new version in the log file. As a fallback in
585 case a notification is lost by the unix socket, the log file is
586 checked after 30 seconds of no event.
588 @subsection Configuring incremental propagation
590 The program that runs on the master is @command{ipropd-master} and all
591 clients run @command{ipropd-slave}.
593 Create the file @file{/var/heimdal/slaves} on the master containing all
594 the slaves that the database should be propagated to.  Each line contains
595 the full name of the principal (for example
596 @samp{iprop/hemligare.foo.se@@FOO.SE}).
598 You should already have @samp{iprop/tcp} defined as 2121, in your
599 @file{/etc/services}.  Otherwise, or if you need to use a different port
600 for some peculiar reason, you can use the @kbd{--port} option.  This is
601 useful when you have multiple realms to distribute from one server.
603 Then you need to create those principals that you added in the
604 configuration file.  Create one @samp{iprop/hostname} for the master and
605 for every slave.
608 @example
609 master# /usr/heimdal/sbin/ktutil get iprop/`hostname`
610 @end example
612 @example
613 slave# /usr/heimdal/sbin/ktutil get iprop/`hostname`
614 @end example
617 The next step is to start the @command{ipropd-master} process on the master
618 server.  The @command{ipropd-master} listens on the UNIX domain socket
619 @file{/var/heimdal/signal} to know when changes have been made to the
620 database so they can be propagated to the slaves.  There is also a
621 safety feature of testing the version number regularly (every 30
622 seconds) to see if it has been modified by some means that do not raise
623 this signal.  Then, start @command{ipropd-slave} on all the slaves:
625 @example
626 master# /usr/heimdal/libexec/ipropd-master &
627 slave#  /usr/heimdal/libexec/ipropd-slave master &
628 @end example
630 To manage the iprop log file you should use the @command{iprop-log}
631 command. With it you can dump, truncate and replay the logfile.
633 @node Encryption types and salting, Cross realm, Incremental propagation, Setting up a realm
634 @section Encryption types and salting
635 @cindex Salting
636 @cindex Encryption types
638 The encryption types that the KDC is going to assign by default is
639 possible to change. Since the keys used for user authentication is
640 salted the encryption types are described together with the salt
641 strings.
643 Salting is used to make it harder to pre-calculate all possible
644 keys. Using a salt increases the search space to make it almost
645 impossible to pre-calculate all keys. Salting is the process of mixing a
646 public string (the salt) with the password, then sending it through an
647 encryption type specific string-to-key function that will output the
648 fixed size encryption key.
650 In Kerberos 5 the salt is determined by the encryption type, except in
651 some special cases.
653 In @code{des} there is the Kerberos 4 salt
654 (none at all) or the afs-salt (using the cell (realm in
655 AFS lingo)).
657 In @code{arcfour} (the encryption type that Microsoft Windows 2000 uses)
658 there is no salt. This is to be compatible with NTLM keys in Windows
659 NT 4.
661 @code{[kadmin]default_keys} in @file{krb5.conf} controls
662 what salting to use.
664 The syntax of @code{[kadmin]default_keys} is
665 @samp{[etype:]salt-type[:salt-string]}. @samp{etype} is the encryption
666 type (des-cbc-crc, arcfour-hmac-md5, aes256-cts-hmac-sha1-96),
667 @code{salt-type} is the type of salt (pw-salt or afs3-salt), and the
668 salt-string is the string that will be used as salt (remember that if
669 the salt is appended/prepended, the empty salt "" is the same thing as
670 no salt at all).
672 Common types of salting include
674 @itemize @bullet
675 @item @code{v4} (or @code{des:pw-salt:})
677 The Kerberos 4 salting is using no salt at all. Reason there is colon
678 at the end of the salt string is that it makes the salt the empty
679 string (same as no salt).
681 @item @code{v5} (or @code{pw-salt})
683 @code{pw-salt} uses the default salt for each encryption type is
684 specified for. If the encryption type @samp{etype} isn't given, all
685 default encryption will be used.
687 @item @code{afs3-salt}
689 @code{afs3-salt} is the salt that is used with Transarc kaserver. It's
690 the cell name appended to the password.
692 @end itemize
694 @node Cross realm, Transit policy, Encryption types and salting, Setting up a realm
695 @section Cross realm
696 @cindex Cross realm
698 Suppose you reside in the realm @samp{MY.REALM}, how do you
699 authenticate to a server in @samp{OTHER.REALM}? Having valid tickets in
700 @samp{MY.REALM} allows you to communicate with Kerberised services in that
701 realm. However, the computer in the other realm does not have a secret
702 key shared with the Kerberos server in your realm.
704 It is possible to share keys between two realms that trust each
705 other. When a client program, such as @command{telnet} or @command{ssh},
706 finds that the other computer is in a different realm, it will try to
707 get a ticket granting ticket for that other realm, but from the local
708 Kerberos server. With that ticket granting ticket, it will then obtain
709 service tickets from the Kerberos server in the other realm.
711 For a two way trust between @samp{MY.REALM} and @samp{OTHER.REALM}
712 add the following principals to each realm. The principals should be
713 @samp{krbtgt/OTHER.REALM@@MY.REALM} and
714 @samp{krbtgt/MY.REALM@@OTHER.REALM} in @samp{MY.REALM}, and
715 @samp{krbtgt/MY.REALM@@OTHER.REALM} and
716 @samp{krbtgt/OTHER.REALM@@MY.REALM}in @samp{OTHER.REALM}.
718 In Kerberos 5 the trust can be configured to be one way. So that
719 users from @samp{MY.REALM} can authenticate to services in
720 @samp{OTHER.REALM}, but not the opposite. In the example above, the
721 @samp{krbtgt/MY.REALM@@OTHER.REALM} then should be removed.
723 The two principals must have the same key, key version number, and the
724 same set of encryption types. Remember to transfer the two keys in a
725 safe manner.
727 @example
728 vr$ klist
729 Credentials cache: FILE:/tmp/krb5cc_913.console
730         Principal: lha@@E.KTH.SE
732   Issued           Expires          Principal
733 May  3 13:55:52  May  3 23:55:54  krbtgt/E.KTH.SE@@E.KTH.SE
735 vr$ telnet -l lha hummel.it.su.se
736 Trying 2001:6b0:5:1095:250:fcff:fe24:dbf...
737 Connected to hummel.it.su.se.
738 Escape character is '^]'.
739 Waiting for encryption to be negotiated...
740 [ Trying mutual KERBEROS5 (host/hummel.it.su.se@@SU.SE)... ]
741 [ Kerberos V5 accepts you as ``lha@@E.KTH.SE'' ]
742 Encryption negotiated.
743 Last login: Sat May  3 14:11:47 from vr.l.nxs.se
744 hummel$ exit
746 vr$ klist
747 Credentials cache: FILE:/tmp/krb5cc_913.console
748         Principal: lha@@E.KTH.SE
750   Issued           Expires          Principal
751 May  3 13:55:52  May  3 23:55:54  krbtgt/E.KTH.SE@@E.KTH.SE
752 May  3 13:55:56  May  3 23:55:54  krbtgt/SU.SE@@E.KTH.SE
753 May  3 14:10:54  May  3 23:55:54  host/hummel.it.su.se@@SU.SE
755 @end example
757 @node Transit policy, Setting up DNS, Cross realm, Setting up a realm
758 @section Transit policy
759 @cindex Transit policy
761 Under some circumstances, you may not wish to set up direct
762 cross-realm trust with every realm to which you wish to authenticate
763 or from which you wish to accept authentications. Kerberos supports
764 multi-hop cross-realm trust where a client principal in realm A
765 authenticates to a service in realm C through a realm B with which
766 both A and C have cross-realm trust relationships. In this situation,
767 A and C need not set up cross-realm principals between each other.
769 If you want to use cross-realm authentication through an intermediate
770 realm, it must be explicitly allowed by either the KDCs for the realm
771 to which the client is authenticating (in this case, realm C), or the
772 server receiving the request. This is done in @file{krb5.conf} in the
773 @code{[capaths]} section.
775 In addition, the client in realm A need to be configured to know how
776 to reach realm C via realm B. This can be done either on the client or
777 via KDC configuration in the KDC for realm A.
779 @subsection Allowing cross-realm transits
781 When the ticket transits through a realm to another realm, the
782 destination realm adds its peer to the "transited-realms" field in the
783 ticket. The field is unordered, since there is no way to know if know
784 if one of the transited-realms changed the order of the list. For the
785 authentication to be accepted by the final destination realm, all of
786 the transited realms must be listed as trusted in the @code{[capaths]}
787 configuration, either in the KDC for the destination realm or on the
788 server receiving the authentication.
790 The syntax for @code{[capaths]} section is:
792 @example
793 [capaths]
794         CLIENT-REALM = @{
795                 SERVER-REALM = PERMITTED-CROSS-REALMS ...
796         @}
797 @end example
799 In the following example, the realm @code{STACKEN.KTH.SE} only has
800 direct cross-realm set up with @code{KTH.SE}.  @code{KTH.SE} has
801 direct cross-realm set up with @code{STACKEN.KTH.SE} and @code{SU.SE}.
802 @code{DSV.SU.SE} only has direct cross-realm set up with @code{SU.SE}.
803 The goal is to allow principals in the @code{DSV.SU.SE} or
804 @code{SU.SE} realms to authenticate to services in
805 @code{STACKEN.KTH.SE}.  This is done with the following
806 @code{[capaths]} entry on either the server accepting authentication
807 or on the KDC for @code{STACKEN.KTH.SE}.
809 @example
810 [capaths]
811         SU.SE = @{
812                     STACKEN.KTH.SE = KTH.SE
813         @}
814         DSV.SU.SE = @{
815                     STACKEN.KTH.SE = SU.SE KTH.SE
816         @}
817 @end example
819 The first entry allows cross-realm authentication from clients in
820 @code{SU.SE} transiting through @code{KTH.SE} to
821 @code{STACKEN.KTH.SE}.  The second entry allows cross-realm
822 authentication from clients in @code{DSV.SU.SE} transiting through
823 both @code{SU.SE} and @code{KTH.SE} to @code{STACKEN.KTH.SE}.
825 Be careful of which realm goes where; it's easy to put realms in the
826 wrong place.  The block is tagged with the client realm (the realm of
827 the principal authenticating), and the realm before the equal sign is
828 the final destination realm: the realm to which the client is
829 authenticating.  After the equal sign go all the realms that the
830 client transits through.
832 The order of the @code{PERMITTED-CROSS-REALMS} is not important when
833 doing transit cross realm verification.
835 @subsection Configuring client cross-realm transits
837 The @code{[capaths]} section is also used for another purpose: to tell
838 clients which realm to transit through to reach a realm with which
839 their local realm does not have cross-realm trust.  This can be done
840 by either putting a @code{[capaths]} entry in the configuration of the
841 client or by putting the entry in the configuration of the KDC for the
842 client's local realm.  In the latter case, the KDC will then hand back
843 a referral to the client when the client requests a cross-realm ticket
844 to the destination realm, telling the client to try to go through an
845 intermediate realm.
847 For client configuration, the order of @code{PERMITTED-CROSS-REALMS}
848 is significant, since only the first realm in this section (after the
849 equal sign) is used by the client.
851 For example, again consider the @code{[capaths]} entry above for the
852 case of a client in the @code{SU.SE} realm, and assume that the client
853 or the @code{SU.SE} KDC has that @code{[capaths]} entry.  If the
854 client attempts to authenticate to a service in the
855 @code{STACKEN.KTH.SE} realm, that entry says to first authenticate
856 cross-realm to the @code{KTH.SE} realm (the first realm listed in the
857 @code{PERMITTED-CROSS-REALMS} section), and then from there to
858 @code{STACKEN.KTH.SE}.
860 Each entry in @code{[capaths]} can only give the next hop, since only
861 the first realm in @code{PERMITTED-CROSS-REALMS} is used.  If, for
862 instance, a client in @code{DSV.SU.SE} had a @code{[capaths]}
863 configuration as above but without the first block for @code{SU.SE},
864 they would not be able to reach @code{STACKEN.KTH.SE}.  They would get
865 as far as @code{SU.SE} based on the @code{DSV.SU.SE} entry in
866 @code{[capaths]} and then attempt to go directly from there to
867 @code{STACKEN.KTH.SE} and get stuck (unless, of course, the
868 @code{SU.SE} KDC had the additional entry required to tell the client
869 to go through @code{KTH.SE}).
871 @subsection Active Directory forest example
873 One common place where a @code{[capaths]} configuration is desirable
874 is with Windows Active Directory forests.  One common Active Directory
875 configuration is to have one top-level Active Directory realm but then
876 divide systems, services, and users into child realms (perhaps based
877 on organizational unit).  One generally establishes cross-realm trust
878 only with the top-level realm, and then uses transit policy to permit
879 authentications to and from the child realms.
881 For example, suppose an organization has a Heimdal realm
882 @code{EXAMPLE.COM}, a Windows Active Directory realm
883 @code{WIN.EXAMPLE.COM}, and then child Active Directory realms
884 @code{ENGR.WIN.EXAMPLE.COM} and @code{SALES.WIN.EXAMPLE.COM}.  The
885 goal is to allow users in any of these realms to authenticate to
886 services in any of these realms.  The @code{EXAMPLE.COM} KDC (and
887 possibly client) configuration should therefore contain a
888 @code{[capaths]} section as follows:
890 @example
891 [capaths]
892         ENGR.WIN.EXAMPLE.COM = @{
893                 EXAMPLE.COM = WIN.EXAMPLE.COM
894         @}
895         SALES.WIN.EXAMPLE.COM = @{
896                 EXAMPLE.COM = WIN.EXAMPLE.COM
897         @}
898         EXAMPLE.COM = @{
899                 ENGR.WIN.EXAMPLE.COM = WIN.EXAMPLE.COM
900                 SALES.WIN.EXAMPLE.COM = WIN.EXAMPLE.COM
901         @}
902 @end example
904 The first two blocks allow clients in the @code{ENGR.WIN.EXAMPLE.COM}
905 and @code{SALES.WIN.EXAMPLE.COM} realms to authenticate to services in
906 the @code{EXAMPLE.COM} realm.  The third block tells the client (or
907 tells the KDC to tell the client via referrals) to transit through
908 @code{WIN.EXAMPLE.COM} to reach these realms.  Both sides of the
909 configuration are needed for bi-directional transited cross-realm
910 authentication.
912 @c To test the cross realm configuration, use:
913 @c    kmumble transit-check client server transit-realms ...
915 @node Setting up DNS, Using LDAP to store the database, Transit policy, Setting up a realm
916 @section Setting up DNS
917 @cindex Setting up DNS
919 @subsection Using DNS to find KDC
921 If there is information about where to find the KDC or kadmind for a
922 realm in the @file{krb5.conf} for a realm, that information will be
923 preferred, and DNS will not be queried.
925 Heimdal will try to use DNS to find the KDCs for a realm. First it
926 will try to find a @code{SRV} resource record (RR) for the realm. If no
927 SRV RRs are found, it will fall back to looking for an @code{A} RR for
928 a machine named kerberos.REALM, and then kerberos-1.REALM, etc
930 Adding this information to DNS minimises the client configuration (in
931 the common case, resulting in no configuration needed) and allows the
932 system administrator to change the number of KDCs and on what machines
933 they are running without caring about clients.
935 The downside of using DNS is that the client might be fooled to use the
936 wrong server if someone fakes DNS replies/data, but storing the IP
937 addresses of the KDC on all the clients makes it very hard to change
938 the infrastructure.
940 An example of the configuration for the realm @code{EXAMPLE.COM}:
942 @example
944 $ORIGIN example.com.
945 _kerberos._tcp          SRV     10 1 88 kerberos.example.com.
946 _kerberos._udp          SRV     10 1 88 kerberos.example.com.
947 _kerberos._tcp          SRV     10 1 88 kerberos-1.example.com.
948 _kerberos._udp          SRV     10 1 88 kerberos-1.example.com.
949 _kpasswd._udp           SRV     10 1 464 kerberos.example.com.
950 _kerberos-adm._tcp      SRV     10 1 749 kerberos.example.com.
952 @end example
954 More information about DNS SRV resource records can be found in
955 RFC-2782 (A DNS RR for specifying the location of services (DNS SRV)).
957 @subsection Using DNS to map hostname to Kerberos realm
959 Heimdal also supports a way to lookup a realm from a hostname. This to
960 minimise configuration needed on clients. Using this has the drawback
961 that clients can be redirected by an attacker to realms within the
962 same cross realm trust and made to believe they are talking to the
963 right server (since Kerberos authentication will succeed).
965 An example configuration that informs clients that for the realms
966 it.example.com and srv.example.com, they should use the realm
967 EXAMPLE.COM:
969 @example
971 $ORIGIN example.com.
972 _kerberos.it            TXT     "EXAMPLE.COM"
973 _kerberos.srv           TXT     "EXAMPLE.COM"
975 @end example
977 @node Using LDAP to store the database, Providing Kerberos credentials to servers and programs, Setting up DNS, Setting up a realm
978 @section Using LDAP to store the database
979 @cindex Using the LDAP backend
981 This document describes how to install the LDAP backend for
982 Heimdal. Note that before attempting to configure such an
983 installation, you should be aware of the implications of storing
984 private information (such as users' keys) in a directory service
985 primarily designed for public information. Nonetheless, with a
986 suitable authorisation policy, it is possible to set this up in a
987 secure fashion. A knowledge of LDAP, Kerberos, and C is necessary to
988 install this backend. The HDB schema was devised by Leif Johansson.
990 This assumes, OpenLDAP 2.3 or later.
992 Requirements:
994 @itemize @bullet
996 @item
997 A current release of Heimdal, configured with
998 @code{--with-openldap=/usr/local} (adjust according to where you have
999 installed OpenLDAP).
1001 You can verify that you manage to configure LDAP support by running
1002 @file{kdc --builtin-hdb}, and checking that @samp{ldap:} is one entry
1003 in the list.
1005 Its also possible to configure the ldap backend as a shared module,
1006 see option --hdb-openldap-module to configure.
1008 @item
1009 Configure OpenLDAP with @kbd{--enable-local} to enable the local transport.
1011 @item
1012 Add the hdb schema to the LDAP server, it's included in the source-tree
1013 in @file{lib/hdb/hdb.schema}. Example from slapd.conf:
1015 @example
1016 include /usr/local/etc/openldap/schema/hdb.schema
1017 @end example
1019 @item
1020 Configure the LDAP server ACLs to accept writes from clients over the
1021 local transport. For example:
1023 @example
1024 access to *
1025         by dn.exact="uid=heimdal,dc=services,dc=example,dc=com" write
1026         ...
1028 authz-regexp "gidNumber=.*\\\+uidNumber=0,cn=peercred,cn=external,cn=auth''
1029         "uid=heimdal,dc=services,dc=example,dc=com"
1031 @end example
1033 The sasl-regexp is for mapping between the SASL/EXTERNAL and a user in
1034 a tree.  The user that the key is mapped to should be have a
1035 krb5Principal aux object with krb5PrincipalName set so that the
1036 ``creator'' and ``modifier'' is right in @file{kadmin}.
1038 Another option is to create an admins group and add the dn to that
1039 group.
1041 Since Heimdal talks to the LDAP server over a UNIX domain socket, and
1042 uses external sasl authentication, it's not possible to require
1043 security layer quality (ssf in cyrus-sasl lingo). So that requirement
1044 has to be turned off in OpenLDAP @command{slapd} configuration file
1045 @file{slapd.conf}.
1047 @example
1048 sasl-secprops minssf=0
1049 @end example
1051 @item
1053 Start @command{slapd} with the local listener (as well as the default TCP/IP
1054 listener on port 389) as follows:
1056 @example
1057     slapd -h "ldapi:/// ldap:///"
1058 @end example
1060 Note: These is a bug in @command{slapd} where it appears to corrupt the krb5Key
1061 binary attribute on shutdown. This may be related to our use of the V3
1062 schema definition syntax instead of the old UMich-style, V2 syntax.
1064 @item
1065 You should specify the distinguished name under which your
1066 principals will be stored in @file{krb5.conf}. Also you need to
1067 enter the path to the kadmin acl file:
1070 @example
1071 [kdc]
1072         database = @{
1073                 dbname = ldap:ou=KerberosPrincipals,dc=example,dc=com
1074                 hdb-ldap-structural-object = inetOrgPerson
1075                 acl_file = /path/to/kadmind.acl
1076                 mkey_file = /path/to/mkey
1077         @}
1078 @end example
1080 @samp{mkey_file} can be excluded if you feel that you trust your ldap
1081 directory to have the raw keys inside it.  The
1082 hdb-ldap-structural-object is not necessary if you do not need Samba
1083 comatibility.
1087 @item
1088 Once you have built Heimdal and started the LDAP server, run kadmin
1089 (as usual) to initialise the database. Note that the instructions for
1090 stashing a master key are as per any Heimdal installation.
1092 @example
1093 kdc# kadmin -l
1094 kadmin> init EXAMPLE.COM
1095 Realm max ticket life [unlimited]:
1096 Realm max renewable ticket life [unlimited]:
1097 kadmin> add lukeh
1098 Max ticket life [1 day]:
1099 Max renewable life [1 week]:
1100 Principal expiration time [never]:
1101 Password expiration time [never]:
1102 Attributes []:
1103 lukeh@@EXAMPLE.COM's Password:
1104 Verifying password - lukeh@@EXAMPLE.COM's Password:
1105 kadmin> exit
1106 @end example
1108 Verify that the principal database has indeed been stored in the
1109 directory with the following command:
1111 @example
1112 kdc# ldapsearch -L -h localhost -D cn=manager \
1113  -w secret -b ou=KerberosPrincipals,dc=example,dc=com \
1114  'objectclass=krb5KDCEntry'
1115 @end example
1117 @item
1118 Now consider adding indexes to the database to speed up the access, at
1119 least theses should be added to slapd.conf.
1121 @example
1122 index   objectClass             eq
1123 index   cn                      eq,sub,pres
1124 index   uid                     eq,sub,pres
1125 index   displayName             eq,sub,pres
1126 index   krb5PrincipalName       eq
1127 @end example
1129 @end itemize
1131 @subsection smbk5pwd overlay
1133 The smbk5pwd overlay, updates the krb5Key and krb5KeyVersionNumber
1134 appropriately when it receives an LDAP Password change Extended
1135 Operation:
1137 @url{http://www.openldap.org/devel/cvsweb.cgi/contrib/slapd-modules/smbk5pwd/README?hideattic=1&sortbydate=0}
1139 @subsection Troubleshooting guide
1141 @url{https://sec.miljovern.no/bin/view/Info/TroubleshootingGuide}
1144 @subsection Using Samba LDAP password database
1145 @cindex Samba
1147 @c @node Using Samba LDAP password database, Providing Kerberos credentials to servers and programs, Using LDAP to store the database, Setting up a realm
1148 @c @section Using Samba LDAP password database
1150 The Samba domain and the Kerberos realm can have different names since
1151 arcfour's string to key functions principal/realm independent.  So now
1152 will be your first and only chance name your Kerberos realm without
1153 needing to deal with old configuration files.
1155 First, you should set up Samba and get that working with LDAP backend.
1157 Now you can proceed as in @xref{Using LDAP to store the database}.
1158 Heimdal will pick up the Samba LDAP entries if they are in the same
1159 search space as the Kerberos entries.
1161 @node Providing Kerberos credentials to servers and programs, Setting up PK-INIT, Using LDAP to store the database, Setting up a realm
1162 @section Providing Kerberos credentials to servers and programs
1164 Some services require Kerberos credentials when they start to make
1165 connections to other services or need to use them when they have started.
1167 The easiest way to get tickets for a service is to store the key in a
1168 keytab. Both ktutil get and kadmin ext can be used to get a
1169 keytab. ktutil get is better in that way it changes the key/password
1170 for the user. This is also the problem with ktutil. If ktutil is used
1171 for the same service principal on several hosts, they keytab will only
1172 be useful on the last host. In that case, run the extract command on
1173 one host and then securely copy the keytab around to all other hosts
1174 that need it.
1176 @example
1177 host# ktutil -k /etc/krb5-service.keytab \
1178       get -p lha/admin@@EXAMPLE.ORG service-principal@@EXAMPLE.ORG
1179 lha/admin@@EXAMPLE.ORG's Password:
1180 @end example
1182 To get a Kerberos credential file for the service, use kinit in the
1183 @kbd{--keytab} mode. This will not ask for a password but instead fetch the
1184 key from the keytab.
1186 @example
1187 service@@host$ kinit --cache=/var/run/service_krb5_cache \
1188                --keytab=/etc/krb5-service.keytab \
1189        service-principal@@EXAMPLE.ORG
1190 @end example
1192 Long running services might need credentials longer then the
1193 expiration time of the tickets. kinit can run in a mode that refreshes
1194 the tickets before they expire. This is useful for services that write
1195 into AFS and other distributed file systems using Kerberos. To run the
1196 long running script, just append the program and arguments (if any)
1197 after the principal. kinit will stop refreshing credentials and remove
1198 the credentials when the script-to-start-service exits.
1200 @example
1201 service@@host$ kinit --cache=/var/run/service_krb5_cache \
1202        --keytab=/etc/krb5-service.keytab \
1203        service-principal@@EXAMPLE.ORG \
1204        script-to-start-service argument1 argument2
1205 @end example
1208 @node Setting up PK-INIT, Debugging Kerberos problems, Providing Kerberos credentials to servers and programs, Setting up a realm
1209 @section Setting up PK-INIT
1211 PK-INIT leverages an existing PKI (public key infrastructure), using
1212 certificates to get the initial ticket (usually the krbtgt
1213 ticket-granting ticket).
1215 To use PK-INIT you must first have a PKI. If you don't have one, it is
1216 time to create it. You should first read the whole chapter of the
1217 document to see the requirements imposed on the CA software.
1219 A mapping between the PKI certificate and what principals that
1220 certificate is allowed to use must exist. There are several ways to do
1221 this. The administrator can use a configuration file, store the
1222 principal in the SubjectAltName extension of the certificate, or store
1223 the mapping in the principals entry in the kerberos database.
1225 @section Certificates
1227 This section documents the requirements on the KDC and client
1228 certificates and the format used in the id-pkinit-san OtherName
1229 extention.
1231 @subsection KDC certificate
1233 The certificate for the KDC has serveral requirements.
1235 First, the certificate should have an Extended Key Usage (EKU)
1236 id-pkkdcekuoid (1.3.6.1.5.2.3.5) set. Second, there must be a
1237 subjectAltName otherName using OID id-pkinit-san (1.3.6.1.5.2.2) in
1238 the type field and a DER encoded KRB5PrincipalName that matches the
1239 name of the TGS of the target realm.  Also, if the certificate has a
1240 nameConstraints extention with a Generalname with dNSName or iPAdress,
1241 it must match the hostname or adress of the KDC.
1243 The client is not required by the standard to check the server
1244 certificate for this information if the client has external
1245 information confirming which certificate the KDC is supposed to be
1246 using. However, adding this information to the KDC certificate removes
1247 the need to specially configure the client to recognize the KDC
1248 certificate.
1250 Remember that if the client would accept any certificate as the KDC's
1251 certificate, the client could be fooled into trusting something that
1252 isn't a KDC and thus expose the user to giving away information (like
1253 a password or other private information) that it is supposed to keep
1254 secret.
1256 @subsection Client certificate
1258 The client certificate may need to have a EKU id-pkekuoid
1259 (1.3.6.1.5.2.3.4) set depending on the certifiate on the KDC.
1261 It possible to store the principal (if allowed by the KDC) in the
1262 certificate and thus delegate responsibility to do the mapping between
1263 certificates and principals to the CA.
1265 This behavior is controlled by KDC configuration option:
1267 @example
1268 [kdc]
1269         pkinit_principal_in_certificate = yes
1270 @end example
1272 @subsubsection Using KRB5PrincipalName in id-pkinit-san
1274 The OtherName extention in the GeneralName is used to do the mapping
1275 between certificate and principal.  For the KDC certificate, this
1276 stores the krbtgt principal name for that KDC.  For the client
1277 certificate, this stores the principal for which that certificate is
1278 allowed to get tickets.
1280 The principal is stored in a SubjectAltName in the certificate using
1281 OtherName. The OID in the type is id-pkinit-san.
1283 @example
1284 id-pkinit-san OBJECT IDENTIFIER ::= @{ iso (1) org (3) dod (6)
1285 internet (1) security (5) kerberosv5 (2) 2 @}
1286 @end example
1288 The data part of the OtherName is filled with the following DER
1289 encoded ASN.1 structure:
1291 @example
1292 KRB5PrincipalName ::= SEQUENCE @{
1293         realm [0] Realm,
1294         principalName [1] PrincipalName
1296 @end example
1298 where Realm and PrincipalName is defined by the Kerberos ASN.1
1299 specification.
1301 @section Naming certificate using hx509
1303 hx509 is the X.509 software used in Heimdal to handle
1304 certificates. hx509 supports several different syntaxes for specifying
1305 certificate files or formats. Several formats may be used:  PEM,
1306 certificates embedded in PKCS#12 files, certificates embedded in
1307 PKCS#11 devices, and raw DER encoded certificates.
1309 Those formats may be specified as follows:
1311 @table @asis
1313 @item DIR:
1315 DIR specifies a directory which contains certificates in the DER or
1316 PEM format.
1318 The main feature of DIR is that the directory is read on demand when
1319 iterating over certificates. This allows applications, in some
1320 situations, to avoid having to store all certificates in memory.  It's
1321 very useful for tests that iterate over large numbers of certificates.
1323 The syntax is:
1325 @example
1326 DIR:/path/to/der/files
1327 @end example
1329 @item FILE:
1331 FILE: specifies a file that contains a certificate or private key.
1332 The file can be either a PEM (openssl) file or a raw DER encoded
1333 certificate. If it's a PEM file, it can contain several keys and
1334 certificates and the code will try to match the private key and
1335 certificate together. Multiple files may be specified, separated by
1336 commas.
1338 It's useful to have one PEM file that contains all the trust anchors.
1340 The syntax is:
1342 @example
1343 FILE:certificate.pem,private-key.key,other-cert.pem,....
1344 @end example
1346 @item PKCS11:
1348 PKCS11: is used to handle smartcards via PKCS#11 drivers, such as
1349 soft-token, opensc, or muscle. The argument specifies a shared object
1350 that implements the PKCS#11 API. The default is to use all slots on
1351 the device/token.
1353 The syntax is:
1355 @example
1356 PKCS11:shared-object.so
1357 @end example
1359 @item PKCS12:
1361 PKCS12: is used to handle PKCS#12 files. PKCS#12 files commonly have
1362 the extension pfx or p12.
1364 The syntax is:
1366 @example
1367 PKCS12:/path/to/file.pfx
1368 @end example
1370 @end table
1372 @section Configure the Kerberos software
1374 First configure the client's trust anchors and what parameters to
1375 verify. See the subsections below for how to do that. Then, you can
1376 use kinit to get yourself tickets. For example:
1378 @example
1379 $ kinit -C FILE:$HOME/.certs/lha.crt,$HOME/.certs/lha.key lha@@EXAMPLE.ORG
1380 Enter your private key passphrase:
1381 : lha@@nutcracker ; klist
1382 Credentials cache: FILE:/tmp/krb5cc_19100a
1383         Principal: lha@@EXAMPLE.ORG
1385   Issued           Expires          Principal
1386 Apr 20 02:08:08  Apr 20 12:08:08  krbtgt/EXAMPLE.ORG@@EXAMPLE.ORG
1387 @end example
1389 Using PKCS#11 it can look like this instead:
1391 @example
1392 $ kinit -C PKCS11:/usr/heimdal/lib/hx509.so lha@@EXAMPLE.ORG
1393 PIN code for SoftToken (slot):
1394 $ klist
1395 Credentials cache: API:4
1396         Principal: lha@@EXAMPLE.ORG
1398   Issued           Expires          Principal
1399 Mar 26 23:40:10  Mar 27 09:40:10  krbtgt/EXAMPLE.ORG@@EXAMPLE.ORG
1400 @end example
1402 TODO: Write about the KDC.
1404 @section Configure the client
1406 @example
1407 [appdefaults]
1408         pkinit_anchors = FILE:/path/to/trust-anchors.pem
1410 [realms]
1411         EXAMPLE.COM = @{
1412                 pkinit_require_eku = true
1413                 pkinit_require_krbtgt_otherName = true
1414                 pkinit_win2k = no
1415                 pkinit_win2k_require_binding = yes
1416         @}
1418 @end example
1420 @section Configure the KDC
1422 @example
1423 [kdc]
1424         enable-pkinit = yes
1425         pkinit_identity = FILE:/secure/kdc.crt,/secure/kdc.key
1426         pkinit_anchors = FILE:/path/to/trust-anchors.pem
1427         pkinit_pool = PKCS12:/path/to/useful-intermediate-certs.pfx
1428         pkinit_pool = FILE:/path/to/other-useful-intermediate-certs.pem
1429         pkinit_allow_proxy_certificate = no
1430         pkinit_win2k_require_binding = yes
1431         pkinit_principal_in_certificate = no
1432 @end example
1434 @subsection Using pki-mapping file
1436 Note that the file name is space sensitive.
1438 @example
1439 # cat /var/heimdal/pki-mapping
1440 # comments starts with #
1441 lha@@EXAMPLE.ORG:C=SE,O=Stockholm universitet,CN=Love,UID=lha
1442 lha@@EXAMPLE.ORG:CN=Love,UID=lha
1443 @end example
1445 @subsection Using the Kerberos database
1447 @section Use hxtool to create certificates
1449 @subsection Generate certificates
1451 First, you need to generate a CA certificate. This example creates a
1452 CA certificate that will be valid for 10 years.
1454 You need to change --subject in the command below to something
1455 appropriate for your site.
1457 @example
1458 hxtool issue-certificate \
1459     --self-signed \
1460     --issue-ca \
1461     --generate-key=rsa \
1462     --subject="CN=CA,DC=test,DC=h5l,DC=se" \
1463     --lifetime=10years \
1464     --certificate="FILE:ca.pem"
1465 @end example
1467 The KDC needs to have a certificate, so generate a certificate of the
1468 type ``pkinit-kdc'' and set the PK-INIT specifial SubjectAltName to the
1469 name of the krbtgt of the realm.
1471 You need to change --subject and --pk-init-principal in the command
1472 below to something appropriate for your site.
1474 @example
1475 hxtool issue-certificate \
1476     --ca-certificate=FILE:ca.pem \
1477     --generate-key=rsa \
1478     --type="pkinit-kdc" \
1479     --pk-init-principal="krbtgt/TEST.H5L.SE@@TEST.H5L.SE" \
1480     --subject="uid=kdc,DC=test,DC=h5l,DC=se" \
1481     --certificate="FILE:kdc.pem"
1482 @end example
1484 The users also needs to have certificates. For your first client,
1485 generate a certificate of type ``pkinit-client''. The client doesn't
1486 need to have the PK-INIT SubjectAltName set; you can have the Subject
1487 DN in the ACL file (pki-mapping) instead.
1489 You need to change --subject and --pk-init-principal in the command
1490 below to something appropriate for your site. You can omit
1491 --pk-init-principal if you're going to use the ACL file instead.
1493 @example
1494 hxtool issue-certificate \
1495     --ca-certificate=FILE:ca.pem \
1496     --generate-key=rsa \
1497     --type="pkinit-client" \
1498     --pk-init-principal="lha@@TEST.H5L.SE" \
1499     --subject="uid=lha,DC=test,DC=h5l,DC=se" \
1500     --certificate="FILE:user.pem"
1501 @end example
1503 @subsection Validate the certificate
1505 hxtool also contains a tool that will validate certificates according
1506 to rules from the PKIX document. These checks are not complete, but
1507 they provide a good test of whether you got all of the basic bits
1508 right in your certificates.
1510 @example
1511 hxtool validate FILE:user.pem
1512 @end example
1514 @section Use OpenSSL to create certificates
1516 This section tries to give the CA owners hints how to create
1517 certificates using OpenSSL (or CA software based on OpenSSL).
1519 @subsection Using OpenSSL to create certificates with krb5PrincipalName
1521 To make OpenSSL create certificates with krb5PrincipalName, use an
1522 @file{openssl.cnf} as described below. To see a complete example of
1523 creating client and KDC certificates, see the test-data generation
1524 script @file{lib/hx509/data/gen-req.sh} in the source-tree. The
1525 certicates it creates are used to test the PK-INIT functionality in
1526 @file{tests/kdc/check-kdc.in}.
1528 To use this example you have to use OpenSSL 0.9.8a or later.
1530 @example
1532 [user_certificate]
1533 subjectAltName=otherName:1.3.6.1.5.2.2;SEQUENCE:princ_name
1535 [princ_name]
1536 realm = EXP:0, GeneralString:MY.REALM
1537 principal_name = EXP:1, SEQUENCE:principal_seq
1539 [principal_seq]
1540 name_type = EXP:0, INTEGER:1
1541 name_string = EXP:1, SEQUENCE:principals
1543 [principals]
1544 princ1 = GeneralString:userid
1546 @end example
1548 Command usage:
1550 @example
1551 openssl x509 -extensions user_certificate
1552 openssl ca -extensions user_certificate
1553 @end example
1556 @c --- ms certificate
1558 @c [ new_oids ]
1559 @c msCertificateTemplateName       = 1.3.6.1.4.1.311.20.2
1562 @c [ req_smartcard ]
1563 @c keyUsage                = digitalSignature, keyEncipherment
1564 @c extendedKeyUsage        = msSmartcardLogin, clientAuth
1565 @c msCertificateTemplateName       = ASN1:BMP:SmartcardLogon
1566 @c subjectAltName          = otherName:msUPN;UTF8:lukeh@dsg.padl.com
1567 @c #subjectAltName         = email:copy
1570 @section Using PK-INIT with Windows
1572 @subsection Client configration
1574 Clients using a Windows KDC with PK-INIT need configuration since
1575 windows uses pre-standard format and this can't be autodetected.
1577 The pkinit_win2k_require_binding option requires the reply for the KDC
1578 to be of the new, secure, type that binds the request to
1579 reply. Before, clients could fake the reply from the KDC. To use this
1580 option you have to apply a fix from Microsoft.
1582 @example
1583 [realms]
1584         MY.MS.REALM = @{
1585                 pkinit_win2k = yes
1586                 pkinit_win2k_require_binding = no
1587         @}
1588 @end example
1590 @subsection Certificates
1592 The client certificates need to have the extended keyusage ``Microsoft
1593 Smartcardlogin'' (openssl has the OID shortname msSmartcardLogin).
1595 See Microsoft Knowledge Base Article - 281245 ``Guidelines for Enabling
1596 Smart Card Logon with Third-Party Certification Authorities'' for a
1597 more extensive description of how set setup an external CA so that it
1598 includes all the information required to make a Windows KDC happy.
1600 @subsection Configure Windows 2000 CA
1602 To enable Microsoft Smartcardlogin for certificates in your Windows
1603 2000 CA, you want to look at Microsoft Knowledge Base Article - 313274
1604 ``HOW TO: Configure a Certification Authority to Issue Smart Card
1605 Certificates in Windows''.
1607 @node Debugging Kerberos problems, , Setting up PK-INIT, Setting up a realm
1608 @section Debugging Kerberos problems
1610 To debug Kerberos client and server problems you can enable debug
1611 traceing by adding the following to @file{/etc/krb5,conf}. Note that the
1612 trace logging is sparse at the moment, but will continue to improve.
1614 @example
1615 [logging]
1616         libkrb5 = 0-/SYSLOG:
1617 @end example