Release 0.8.1
[heimdal.git] / doc / hx509.texi
blob3c1ae0e59ff8b70330423ff195f3fd9ebeded7f9
1 \input texinfo @c -*- texinfo -*-
2 @c %**start of header
3 @c $Id$
4 @setfilename hx509.info
5 @settitle HX509
6 @iftex
7 @afourpaper
8 @end iftex
9 @c some sensible characters, please?
10 @tex
11 \input latin1.tex
12 @end tex
13 @setchapternewpage on
14 @syncodeindex pg cp
15 @c %**end of header
17 @c @include version.texi
18 @set UPDATED $Date$
19 @set EDITION 0.1
20 @set VERSION 0.8
22 @ifinfo
23 @dircategory Security
24 @direntry
25 * hx509: (hx509).           The X.509 distribution from KTH
26 @end direntry
27 @end ifinfo
29 @c title page
30 @titlepage
31 @title HX509
32 @subtitle X.509 distribution from KTH
33 @subtitle Edition @value{EDITION}, for version @value{VERSION}
34 @subtitle 2007
35 @author Love Hörnquist Åstrand
36 @author last updated @value{UPDATED}
38 @def@copynext{@vskip 20pt plus 1fil@penalty-1000}
39 @def@copyrightstart{}
40 @def@copyrightend{}
41 @page
42 @copyrightstart
43 Copyright (c) 1994-2007 Kungliga Tekniska Högskolan
44 (Royal Institute of Technology, Stockholm, Sweden).
45 All rights reserved.
47 Redistribution and use in source and binary forms, with or without
48 modification, are permitted provided that the following conditions
49 are met:
51 1. Redistributions of source code must retain the above copyright
52    notice, this list of conditions and the following disclaimer.
54 2. Redistributions in binary form must reproduce the above copyright
55    notice, this list of conditions and the following disclaimer in the
56    documentation and/or other materials provided with the distribution.
58 3. Neither the name of the Institute nor the names of its contributors
59    may be used to endorse or promote products derived from this software
60    without specific prior written permission.
62 THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
63 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
64 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
65 ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
66 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
67 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72 SUCH DAMAGE.
74 @copynext
76 Copyright (C) 1990 by the Massachusetts Institute of Technology
78 Export of this software from the United States of America may
79 require a specific license from the United States Government.
80 It is the responsibility of any person or organization contemplating
81 export to obtain such a license before exporting.
83 WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
84 distribute this software and its documentation for any purpose and
85 without fee is hereby granted, provided that the above copyright
86 notice appear in all copies and that both that copyright notice and
87 this permission notice appear in supporting documentation, and that
88 the name of M.I.T. not be used in advertising or publicity pertaining
89 to distribution of the software without specific, written prior
90 permission.  M.I.T. makes no representations about the suitability of
91 this software for any purpose.  It is provided "as is" without express
92 or implied warranty.
94 @copynext
96 Copyright (c) 1988, 1990, 1993
97      The Regents of the University of California.  All rights reserved.
99 Redistribution and use in source and binary forms, with or without
100 modification, are permitted provided that the following conditions
101 are met:
103 1. Redistributions of source code must retain the above copyright
104    notice, this list of conditions and the following disclaimer.
106 2. Redistributions in binary form must reproduce the above copyright
107    notice, this list of conditions and the following disclaimer in the
108    documentation and/or other materials provided with the distribution.
110 3. Neither the name of the University nor the names of its contributors
111    may be used to endorse or promote products derived from this software
112    without specific prior written permission.
114 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
115 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
116 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
117 ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
118 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
119 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
120 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
121 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
122 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
123 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
124 SUCH DAMAGE.
126 @copynext
128 Copyright 1992 Simmule Turner and Rich Salz.  All rights reserved.
130 This software is not subject to any license of the American Telephone
131 and Telegraph Company or of the Regents of the University of California.
133 Permission is granted to anyone to use this software for any purpose on
134 any computer system, and to alter it and redistribute it freely, subject
135 to the following restrictions:
137 1. The authors are not responsible for the consequences of use of this
138    software, no matter how awful, even if they arise from flaws in it.
140 2. The origin of this software must not be misrepresented, either by
141    explicit claim or by omission.  Since few users ever read sources,
142    credits must appear in the documentation.
144 3. Altered versions must be plainly marked as such, and must not be
145    misrepresented as being the original software.  Since few users
146    ever read sources, credits must appear in the documentation.
148 4. This notice may not be removed or altered.
150 @copynext
152 IMath is Copyright 2002-2005 Michael J. Fromberger
153 You may use it subject to the following Licensing Terms:
155 Permission is hereby granted, free of charge, to any person obtaining
156 a copy of this software and associated documentation files (the
157 "Software"), to deal in the Software without restriction, including
158 without limitation the rights to use, copy, modify, merge, publish,
159 distribute, sublicense, and/or sell copies of the Software, and to
160 permit persons to whom the Software is furnished to do so, subject to
161 the following conditions:
163 The above copyright notice and this permission notice shall be
164 included in all copies or substantial portions of the Software.
166 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
167 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
168 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
169 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
170 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
171 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
172 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
174 @copynext
176 Copyright (c) 2005 Doug Rabson
177 All rights reserved.
179 Redistribution and use in source and binary forms, with or without
180 modification, are permitted provided that the following conditions
181 are met:
182 1. Redistributions of source code must retain the above copyright
183    notice, this list of conditions and the following disclaimer.
184 2. Redistributions in binary form must reproduce the above copyright
185    notice, this list of conditions and the following disclaimer in the
186    documentation and/or other materials provided with the distribution.
188 THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
189 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
190 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
191 ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
192 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
193 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
194 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
195 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
196 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
197 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
198 SUCH DAMAGE.
200 @copyrightend
201 @end titlepage
203 @macro manpage{man, section}
204 @cite{\man\(\section\)}
205 @end macro
207 @c Less filling! Tastes great!
208 @iftex
209 @parindent=0pt
210 @global@parskip 6pt plus 1pt
211 @global@chapheadingskip = 15pt plus 4pt minus 2pt
212 @global@secheadingskip = 12pt plus 3pt minus 2pt
213 @global@subsecheadingskip = 9pt plus 2pt minus 2pt
214 @end iftex
215 @ifinfo
216 @paragraphindent 0
217 @end ifinfo
219 @ifnottex
220 @node Top, Introduction, (dir), (dir)
221 @top Heimdal
222 @end ifnottex
224 This manual is last updated @value{UPDATED} for version
225 @value{VERSION} of hx509.
227 @menu
228 * Introduction::
229 * What is X.509 ?::
230 * Setting up a CA::
231 * CMS signing and encryption::
233 @detailmenu
234  --- The Detailed Node Listing ---
236 Setting up a CA
238 @c * Issuing certificates::
239 * Creating a CA certificate::
240 * Issuing certificates::
241 @c * Issuing a proxy certificate::
242 @c * Creating a user certificate::
243 @c * Validating a certificate::
244 @c * Validating a certificate path::
245 * Application requirements::
247 CMS signing and encryption
249 * CMS background::
251 @end detailmenu
252 @end menu
254 @node Introduction, What is X.509 ?, Top, Top
255 @chapter Introduction
257 hx509 is a somewhat complete X.509 stack that can handle CMS messages
258 (crypto system used in S/MIME and Kerberos PK-INIT) and basic
259 certificate processing tasks, path construction, path validation, OCSP
260 and CRL validation, PKCS10 message construction, CMS Encrypted (shared
261 secret encrypted), CMS SignedData (certificate signed), and CMS
262 EnvelopedData (certificate encrypted).
264 hx509 can use PKCS11 tokens, PKCS12 files, PEM files, DER encoded files.
266 @node What is X.509 ?, Setting up a CA, Introduction, Top
267 @chapter What is X.509, PKIX, PKCS7 and CMS ? 
269 X.509 is from the beginning created by CCITT (later ITU) for the X.500
270 directory service. But today when people are talking about X.509 they
271 are commonly referring to IETF's PKIX Certificate and CRL Profile of the
272 X.509 v3 certificate standard, as specified in RFC 3280.
274 ITU continues to develop the X.509 standard together in a complicated
275 dance with IETF.
277 X.509 is public key based security system that have associated data
278 stored within a so called certificate. From the beginning X.509 was a
279 strict hierarchical system with one root. This didn't not work so over
280 time X.509 got support for multiple policy roots, bridges, and mesh
281 solutions. You can even use it as a peer to peer system, but this is not
282 very common.
284 @section Type of certificates
286 There are several flavors of certificate in X.509.
288 @itemize @bullet
290 @item Trust anchors
292 Trust anchors are strictly not certificate, but commonly stored in
293 certificate since they are easier to handle then. Trust anchor are the
294 keys that you trust to validate other certificate. This is done by
295 building a path from the certificate you wan to validate to to any of
296 the trust anchors you have.
298 @item End Entity (EE) certificates
300 End entity certificates is the most common type of certificate. End
301 entity certificates can't issue certificate them-self and is used to
302 authenticate and authorize user and services.
304 @item Certification Authority (CA) certificates
306 Certificate authority are certificates that have the right to issue
307 other certificate, they may be End entity certificates or Certificate
308 Authority certificates. There is no limit to how many certificates a CA
309 may issue, but there might other restrictions, like the maximum path
310 depth.
312 @item Proxy certificates
314 Remember that End Entity can't issue certificates by them own, its not
315 really true. There there is an extension called proxy certificates,
316 defined in RFC3820, that allows certificates to be issued by end entity
317 certificates. The service that receives the proxy certificates must have
318 explicitly turned on support for proxy certificates, so their use is
319 somewhat limited.
321 Proxy certificates can be limited by policy stored in the certificate to
322 what they can be used for. This allows users to delegate the proxy
323 certificate to services (by sending over the certificate and private
324 key) so the service can access services on behalf of the user.
326 One example of this would be a print service. The user wants to print a
327 large job in the middle of the night when the printer isn't used that
328 much, so the user creates a proxy certificate with the policy that it
329 can only be used to access files related to this print job, creates the
330 print job description and send both the description and proxy
331 certificate with key over to print service. Later at night will the
332 print service, without the help of the user, access the files for the
333 the print job using the proxy certificate and print the job. Because of
334 the policy (limitation) in the proxy certificate, it can't be used for
335 any other purposes.
337 @end itemize
339 @section Building a path
341 Before validating a path the path must be constructed. Given a
342 certificate (EE, CA, Proxy, or any other type), the path construction
343 algorithm will try to find a path to one of the trust anchors.
345 It start with looking at whom issued the certificate, by name or Key
346 Identifier, and tries to find that certificate while at the same time
347 evaluates the policy.
349 @node Setting up a CA, Creating a CA certificate, What is X.509 ?, Top
350 @chapter Setting up a CA
352 Do not let this chapter scare you off, its just to give you an idea how
353 to complicated setting up a CA can be. If you are just playing around,
354 skip all this and go to the next chapter, @pxref{Creating a CA
355 certificate}.
357 Creating a CA certificate should be more the just creating a
358 certificate, there is the policy of the CA. If its just you and your
359 friend that is playing around then it probably doesn't matter what the
360 policy is. But then it comes to trust in an organisation, it will
361 probably matter more whom your users and sysadmins will find it
362 acceptable to trust.
364 At the same time, try to keep thing simple, its not very hard to run a
365 Certificate authority and the process to get new certificates should
366 simple.
368 Fill all this in later.
370 How do you trust your CA.
372 What is the CA responsibility.
374 Review of CA activity.
376 How much process should it be to issue certificate.
378 Who is allowed to issue certificates.
380 Who is allowed to requests certificates.
382 @node Creating a CA certificate, Issuing certificates, Setting up a CA, Top
383 @section Creating a CA certificate
385 This section describes how to create a CA certificate and what to think
386 about.
388 @subsection Lifetime CA certificate
390 You probably want to create a CA certificate with a long lifetime, 10
391 years at the shortest. This because you don't want to push out the
392 certificate (as a trust anchor) to all you users once again when the old
393 one just expired. A trust anchor can't really expire, but not all
394 software works that way.
396 Keep in mind the security requirements might be different 10-20 years
397 into the future. For example, SHA1 is going to be withdrawn in 2010, so
398 make sure you have enough buffering in your choice of digest/hash
399 algorithms, signature algorithms and key lengths.
401 @subsection Create a CA certificate
403 This command below will create a CA certificate in the file ca.pem.
405 @example
406 hxtool issue-certificate \
407     --self-signed \
408     --issue-ca \
409     --generate-key=rsa \
410     --subject="CN=CertificateAuthority,DC=test,DC=h5l,DC=se" \
411     --lifetime=10years \
412     --certificate="FILE:ca.pem"
413 @end example
415 @subsection Extending lifetime of a CA certificate
417 You just realised that your CA certificate is going to expire soon and
418 that you need replace it with something else, the easiest way to do that
419 is to extend the lifetime of your CA certificate.
421 The example below will extend the CA certificate 10 years into the
422 future. You should compare this new certificate if it contains all the
423 special tweaks as the old certificate had.
425 @example
426 hxtool issue-certificate \
427     --self-signed \
428     --issue-ca \
429     --lifetime="10years" \
430     --template-certificate="FILE:ca.pem" \
431     --template-fields="serialNumber,notBefore,subject,SPKI" \
432     --ca-private-key=FILE:ca.pem \
433     --certificate="FILE:new-ca.pem"
434 @end example
436 @subsection Subordinate CA
438 This example create a new subordinate certificate authority.
440 @example
441 hxtool issue-certificate \
442     --ca-certificate=FILE:ca.pem \
443     --issue-ca \
444     --generate-key=rsa \
445     --subject="CN=CertificateAuthority,DC=dev,DC=test,DC=h5l,DC=se" \
446     --certificate="FILE:dev-ca.pem"
447 @end example
450 @node Issuing certificates, Application requirements, Creating a CA certificate, Top
451 @section Issuing certificates
453 First you'll create a CA certificate, after that you have to deal with
454 your users and servers and issue certificate to them.
456 CA can generate the key for the user.
458 Can receive PKCS10 certificate requests from the users. PKCS10 is a
459 request for a certificate. The user can specified what DN the user wants
460 and what public key. To prove the user have the key, the whole request
461 is signed by the private key of the user.
463 Name space management.
465 What people might want to see.
467 Re-issue certificates just because people moved within the organization.
469 Expose privacy information.
471 Using Sub-component name (+ notation).
473 @node Application requirements, CMS signing and encryption, Issuing certificates, Top
474 @section Application requirements
476 Application have different requirements on certificates. This section
477 tries to expand what they are and how to use hxtool to generate
478 certificates for those services.
480 @subsection HTTPS - server
482 @example
483 hxtool issue-certificate \
484           --subject="CN=www.test.h5l.se,DC=test,DC=h5l,DC=se" \
485           --type="https-server" \
486           --hostname="www.test.h5l.se" \
487           --hostname="www2.test.h5l.se" \
488           ...
489 @end example
491 @subsection HTTPS - client
493 @example
494 hxtool issue-certificate \
495           --subject="UID=testus,DC=test,DC=h5l,DC=se" \
496           --type="https-client" \
497           ...
498 @end example
500 @subsection S/MIME - email
502 There are two things that should be set in S/MIME certificates, one or
503 more email addresses and an extended eku usage (EKU), emailProtection.
505 The email address format used in S/MIME certificates is defined in
506 RFC2822, section 3.4.1 and it should be an ``addr-spec''.
508 There are two ways to specifify email address in certificates. The old
509 ways is in the subject distinguished name, this should not be used. The
510 new way is using a Subject Alternative Name (SAN).
512 But even though email address is stored in certificates, they don't need
513 to, email reader programs are required to accept certificates that
514 doesn't have either of the two methods of storing email in certificates.
515 In that case, they try to protect the user by printing the name of the
516 certificate instead.
518 S/MIME certificate can be used in another special way. They can be
519 issued with a NULL subject distinguished name plus the email in SAN,
520 this is a valid certificate. This is used when you wont want to share
521 more information then you need to.
523 hx509 issue-certificate supports adding the email SAN to certificate by
524 using the --email option, --email also gives an implicit emailProtection
525 eku. If you want to create an certificate without an email address, the
526 option --type=email will add the emailProtection EKU.
528 @example
529 hxtool issue-certificate \
530           --subject="UID=testus-email,DC=test,DC=h5l,DC=se" \
531           --type=email \
532           --email="testus@@test.h5l.se" \
533           ...
534 @end example
536 An example of an certificate without and subject distinguished name with
537 an email address in a SAN.
539 @example
540 hxtool issue-certificate \
541           --subject="" \
542           --type=email \
543           --email="testus@@test.h5l.se" \
544           ...
545 @end example
547 @subsection PK-INIT
549 How to create a certificate for a KDC.
551 @example
552 hxtool issue-certificate \
553     --type="pkinit-kdc" \
554     --pk-init-principal="krbtgt/TEST.H5L.SE@@TEST.H5L.SE" \
555     --hostname kerberos.test.h5l.se \
556     --hostname pal.test.h5l.se \
557     ...
558 @end example
560 How to create a certificate for a user.
562 @example
563 hxtool issue-certificate \
564     --type="pkinit-client" \
565     --pk-init-principal="user@@TEST.H5L.SE" \
566     ...
567 @end example
569 @subsection XMPP/Jabber
571 The jabber server certificate should have a dNSname that is the same as
572 the user entered into the application, not the same as the host name of
573 the machine.
575 @example
576 hxtool issue-certificate \
577           --subject="CN=xmpp1.test.h5l.se,DC=test,DC=h5l,DC=se" \
578           --hostname="xmpp1.test.h5l.se" \
579           --hostname="test.h5l.se" \
580           ...
581 @end example
583 The certificate may also contain a jabber identifier (JID) that, if the
584 receiver allows it, authorises the server or client to use that JID.
586 When storing a JID inside the certificate, both for server and client,
587 its stored inside a UTF8String within an otherName entity inside the
588 subjectAltName, using the OID id-on-xmppAddr (1.3.6.1.5.5.7.8.5).
590 To read more about the requirements, see RFC3920, Extensible Messaging
591 and Presence Protocol (XMPP): Core.
593 hxtool issue-certificate have support to add jid to the certificate
594 using the option --jid.
596 @example
597 hxtool issue-certificate \
598           --subject="CN=Love,DC=test,DC=h5l,DC=se" \
599           --jid="lha@@test.h5l.se" \
600           ...
601 @end example
604 @node CMS signing and encryption, CMS background, Application requirements, Top
605 @chapter CMS signing and encryption
607 CMS is the Cryptographic Message System that among other, is used by
608 S/MIME (secure email) and Kerberos PK-INIT. Its an extended version of
609 the RSA, Inc standard PKCS7.
611 @node CMS background, , CMS signing and encryption, Top
612 @section CMS background
615 @c @shortcontents
616 @contents
618 @bye