1 \input texinfo @c -*- texinfo -*-
4 @setfilename hx509.info
9 @c some sensible characters, please?
20 @set VERSION @value{PACKAGE_VERSION}
26 * hx509: (hx509). The X.509 distribution from KTH
33 @subtitle X.509 distribution from KTH
34 @subtitle Edition @value{EDITION}, for version @value{VERSION}
36 @author Love Hörnquist Åstrand
37 @author last updated @value{UPDATED}
39 @def@copynext{@vskip 20pt plus 1fil@penalty-1000}
44 Copyright (c) 1994-2008 Kungliga Tekniska Högskolan
45 (Royal Institute of Technology, Stockholm, Sweden).
48 Redistribution and use in source and binary forms, with or without
49 modification, are permitted provided that the following conditions
52 1. Redistributions of source code must retain the above copyright
53 notice, this list of conditions and the following disclaimer.
55 2. Redistributions in binary form must reproduce the above copyright
56 notice, this list of conditions and the following disclaimer in the
57 documentation and/or other materials provided with the distribution.
59 3. Neither the name of the Institute nor the names of its contributors
60 may be used to endorse or promote products derived from this software
61 without specific prior written permission.
63 THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
64 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
65 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
66 ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
67 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
68 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
69 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
70 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
71 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
72 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
77 Copyright (c) 1988, 1990, 1993
78 The Regents of the University of California. All rights reserved.
80 Redistribution and use in source and binary forms, with or without
81 modification, are permitted provided that the following conditions
84 1. Redistributions of source code must retain the above copyright
85 notice, this list of conditions and the following disclaimer.
87 2. Redistributions in binary form must reproduce the above copyright
88 notice, this list of conditions and the following disclaimer in the
89 documentation and/or other materials provided with the distribution.
91 3. Neither the name of the University nor the names of its contributors
92 may be used to endorse or promote products derived from this software
93 without specific prior written permission.
95 THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
96 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
97 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
98 ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
99 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
100 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
101 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
102 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
103 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
104 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
109 Copyright 1992 Simmule Turner and Rich Salz. All rights reserved.
111 This software is not subject to any license of the American Telephone
112 and Telegraph Company or of the Regents of the University of California.
114 Permission is granted to anyone to use this software for any purpose on
115 any computer system, and to alter it and redistribute it freely, subject
116 to the following restrictions:
118 1. The authors are not responsible for the consequences of use of this
119 software, no matter how awful, even if they arise from flaws in it.
121 2. The origin of this software must not be misrepresented, either by
122 explicit claim or by omission. Since few users ever read sources,
123 credits must appear in the documentation.
125 3. Altered versions must be plainly marked as such, and must not be
126 misrepresented as being the original software. Since few users
127 ever read sources, credits must appear in the documentation.
129 4. This notice may not be removed or altered.
133 IMath is Copyright 2002-2005 Michael J. Fromberger
134 You may use it subject to the following Licensing Terms:
136 Permission is hereby granted, free of charge, to any person obtaining
137 a copy of this software and associated documentation files (the
138 "Software"), to deal in the Software without restriction, including
139 without limitation the rights to use, copy, modify, merge, publish,
140 distribute, sublicense, and/or sell copies of the Software, and to
141 permit persons to whom the Software is furnished to do so, subject to
142 the following conditions:
144 The above copyright notice and this permission notice shall be
145 included in all copies or substantial portions of the Software.
147 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
148 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
149 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
150 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
151 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
152 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
153 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
158 @macro manpage{man, section}
159 @cite{\man\(\section\)}
162 @c Less filling! Tastes great!
165 @global@parskip 6pt plus 1pt
166 @global@chapheadingskip = 15pt plus 4pt minus 2pt
167 @global@secheadingskip = 12pt plus 3pt minus 2pt
168 @global@subsecheadingskip = 9pt plus 2pt minus 2pt
175 @node Top, Introduction, (dir), (dir)
179 This manual is last updated @value{UPDATED} for version
180 @value{VERSION} of hx509.
186 * CMS signing and encryption::
187 * Certificate matching::
188 * Software PKCS 11 module::
191 --- The Detailed Node Listing ---
195 @c * Issuing certificates::
196 * Creating a CA certificate::
197 * Issuing certificates::
199 @c * Issuing a proxy certificate::
200 @c * Creating a user certificate::
201 @c * Validating a certificate::
202 @c * Validating a certificate path::
203 * Application requirements::
205 CMS signing and encryption
213 Software PKCS 11 module
215 * How to use the PKCS11 module::
220 @node Introduction, What is X.509 ?, Top, Top
221 @chapter Introduction
223 hx509 is a somewhat complete X.509 stack that can handle CMS messages
224 (crypto system used in S/MIME and Kerberos PK-INIT) and basic
225 certificate processing tasks, path construction, path validation, OCSP
226 and CRL validation, PKCS10 message construction, CMS Encrypted (shared
227 secret encrypted), CMS SignedData (certificate signed), and CMS
228 EnvelopedData (certificate encrypted).
230 hx509 can use PKCS11 tokens, PKCS12 files, PEM files, DER encoded files.
232 @node What is X.509 ?, Setting up a CA, Introduction, Top
233 @chapter What is X.509, PKIX, PKCS7 and CMS ?
235 X.509 is from the beginning created by CCITT (later ITU) for the X.500
236 directory service. But today when people are talking about X.509 they
237 are commonly referring to IETF's PKIX Certificate and CRL Profile of the
238 X.509 v3 certificate standard, as specified in RFC 3280.
240 ITU continues to develop the X.509 standard together in a complicated
243 X.509 is public key based security system that have associated data
244 stored within a so called certificate. From the beginning X.509 was a
245 strict hierarchical system with one root. This didn't not work so over
246 time X.509 got support for multiple policy roots, bridges, and mesh
247 solutions. You can even use it as a peer to peer system, but this is not
250 @section Type of certificates
252 There are several flavors of certificate in X.509.
258 Trust anchors are strictly not certificate, but commonly stored in
259 certificate since they are easier to handle then. Trust anchor are the
260 keys that you trust to validate other certificate. This is done by
261 building a path from the certificate you wan to validate to to any of
262 the trust anchors you have.
264 @item End Entity (EE) certificates
266 End entity certificates is the most common type of certificate. End
267 entity certificates can't issue certificate them-self and is used to
268 authenticate and authorize user and services.
270 @item Certification Authority (CA) certificates
272 Certificate authority are certificates that have the right to issue
273 other certificate, they may be End entity certificates or Certificate
274 Authority certificates. There is no limit to how many certificates a CA
275 may issue, but there might other restrictions, like the maximum path
278 @item Proxy certificates
280 Remember that End Entity can't issue certificates by them own, it's not
281 really true. There there is an extension called proxy certificates,
282 defined in RFC3820, that allows certificates to be issued by end entity
283 certificates. The service that receives the proxy certificates must have
284 explicitly turned on support for proxy certificates, so their use is
287 Proxy certificates can be limited by policy stored in the certificate to
288 what they can be used for. This allows users to delegate the proxy
289 certificate to services (by sending over the certificate and private
290 key) so the service can access services on behalf of the user.
292 One example of this would be a print service. The user wants to print a
293 large job in the middle of the night when the printer isn't used that
294 much, so the user creates a proxy certificate with the policy that it
295 can only be used to access files related to this print job, creates the
296 print job description and send both the description and proxy
297 certificate with key over to print service. Later at night will the
298 print service, without the help of the user, access the files for the
299 the print job using the proxy certificate and print the job. Because of
300 the policy (limitation) in the proxy certificate, it can't be used for
305 @section Building a path
307 Before validating a path the path must be constructed. Given a
308 certificate (EE, CA, Proxy, or any other type), the path construction
309 algorithm will try to find a path to one of the trust anchors.
311 It start with looking at whom issued the certificate, by name or Key
312 Identifier, and tries to find that certificate while at the same time
313 evaluates the policy.
315 @node Setting up a CA, Creating a CA certificate, What is X.509 ?, Top
316 @chapter Setting up a CA
318 Do not let this chapter scare you off, it's just to give you an idea how
319 to complicated setting up a CA can be. If you are just playing around,
320 skip all this and go to the next chapter, @pxref{Creating a CA
323 Creating a CA certificate should be more the just creating a
324 certificate, there is the policy of the CA. If it's just you and your
325 friend that is playing around then it probably doesn't matter what the
326 policy is. But then it comes to trust in an organisation, it will
327 probably matter more whom your users and sysadmins will find it
330 At the same time, try to keep thing simple, it's not very hard to run a
331 Certificate authority and the process to get new certificates should
334 Fill all this in later.
336 How do you trust your CA.
338 What is the CA responsibility.
340 Review of CA activity.
342 How much process should it be to issue certificate.
344 Who is allowed to issue certificates.
346 Who is allowed to requests certificates.
348 How to handle certificate revocation, issuing CRLs and maintain OCSP
351 @node Creating a CA certificate, Issuing certificates, Setting up a CA, Top
352 @section Creating a CA certificate
354 This section describes how to create a CA certificate and what to think
357 @subsection Lifetime CA certificate
359 You probably want to create a CA certificate with a long lifetime, 10
360 years at the shortest. This because you don't want to push out the
361 certificate (as a trust anchor) to all you users once again when the old
362 one just expired. A trust anchor can't really expire, but not all
363 software works that way.
365 Keep in mind the security requirements might be different 10-20 years
366 into the future. For example, SHA1 is going to be withdrawn in 2010, so
367 make sure you have enough buffering in your choice of digest/hash
368 algorithms, signature algorithms and key lengths.
370 @subsection Create a CA certificate
372 This command below will create a CA certificate in the file ca.pem.
375 hxtool issue-certificate \
379 --subject="CN=CertificateAuthority,DC=test,DC=h5l,DC=se" \
381 --certificate="FILE:ca.pem"
384 @subsection Extending lifetime of a CA certificate
386 You just realised that your CA certificate is going to expire soon and
387 that you need replace it with something else, the easiest way to do that
388 is to extend the lifetime of your CA certificate.
390 The example below will extend the CA certificate 10 years into the
391 future. You should compare this new certificate if it contains all the
392 special tweaks as the old certificate had.
395 hxtool issue-certificate \
398 --lifetime="10years" \
399 --template-certificate="FILE:ca.pem" \
400 --template-fields="serialNumber,notBefore,subject,SPKI" \
401 --ca-private-key=FILE:ca.pem \
402 --certificate="FILE:new-ca.pem"
405 @subsection Subordinate CA
407 This example create a new subordinate certificate authority.
410 hxtool issue-certificate \
411 --ca-certificate=FILE:ca.pem \
414 --subject="CN=CertificateAuthority,DC=dev,DC=test,DC=h5l,DC=se" \
415 --certificate="FILE:dev-ca.pem"
419 @node Issuing certificates, Issuing CRLs, Creating a CA certificate, Top
420 @section Issuing certificates
422 First you'll create a CA certificate, after that you have to deal with
423 your users and servers and issue certificate to them.
425 CA can generate the key for the user.
427 Can receive PKCS10 certificate requests from the users. PKCS10 is a
428 request for a certificate. The user can specified what DN the user wants
429 and what public key. To prove the user have the key, the whole request
430 is signed by the private key of the user.
432 @subsection Name space management
434 What people might want to see.
436 Re-issue certificates just because people moved within the organization.
438 Expose privacy information.
440 Using Sub-component name (+ notation).
442 @subsection Certificate Revocation, CRL and OCSP
444 Sonetimes people loose smartcard or computers and certificates have to
445 be make not valid any more, this is called revoking certificates. There
446 are two main protocols for doing this Certificate Revocations Lists
447 (CRL) and Online Certificate Status Protocol (OCSP).
449 If you know that the certificate is destroyed then there is no need to
450 revoke the certificate because it can not be used by someone else.
452 The main reason you as a CA administrator have to deal with CRLs however
453 will be that some software require there to be CRLs. Example of this is
454 Windows, so you have to deal with this somehow.
456 @node Issuing CRLs, Application requirements, Issuing certificates, Top
457 @section Issuing CRLs
459 Create an empty CRL with not certificates revoked. Default expiration
460 value is one year from now.
468 Create a CRL with all certificates in the directory
469 @file{/path/to/revoked/dir} included in the CRL as revoked. Also make
470 it expire one month from now.
475 --signer=FILE:ca.pem \
476 --lifetime='1 month' \
477 DIR:/path/to/revoked/dir
480 @node Application requirements, CMS signing and encryption, Issuing CRLs, Top
481 @section Application requirements
483 Application have different requirements on certificates. This section
484 tries to expand what they are and how to use hxtool to generate
485 certificates for those services.
487 @subsection HTTPS - server
490 hxtool issue-certificate \
491 --subject="CN=www.test.h5l.se,DC=test,DC=h5l,DC=se" \
492 --type="https-server" \
493 --hostname="www.test.h5l.se" \
494 --hostname="www2.test.h5l.se" \
498 @subsection HTTPS - client
501 hxtool issue-certificate \
502 --subject="UID=testus,DC=test,DC=h5l,DC=se" \
503 --type="https-client" \
507 @subsection S/MIME - email
509 There are two things that should be set in S/MIME certificates, one or
510 more email addresses and an extended eku usage (EKU), emailProtection.
512 The email address format used in S/MIME certificates is defined in
513 RFC2822, section 3.4.1 and it should be an ``addr-spec''.
515 There are two ways to specifify email address in certificates. The old
516 ways is in the subject distinguished name, this should not be used. The
517 new way is using a Subject Alternative Name (SAN).
519 But even though email address is stored in certificates, they don't need
520 to, email reader programs are required to accept certificates that
521 doesn't have either of the two methods of storing email in certificates.
522 In that case, they try to protect the user by printing the name of the
525 S/MIME certificate can be used in another special way. They can be
526 issued with a NULL subject distinguished name plus the email in SAN,
527 this is a valid certificate. This is used when you wont want to share
528 more information then you need to.
530 hx509 issue-certificate supports adding the email SAN to certificate by
531 using the --email option, --email also gives an implicit emailProtection
532 eku. If you want to create an certificate without an email address, the
533 option --type=email will add the emailProtection EKU.
536 hxtool issue-certificate \
537 --subject="UID=testus-email,DC=test,DC=h5l,DC=se" \
539 --email="testus@@test.h5l.se" \
543 An example of an certificate without and subject distinguished name with
544 an email address in a SAN.
547 hxtool issue-certificate \
550 --email="testus@@test.h5l.se" \
556 How to create a certificate for a KDC.
559 hxtool issue-certificate \
560 --type="pkinit-kdc" \
561 --pk-init-principal="krbtgt/TEST.H5L.SE@@TEST.H5L.SE" \
562 --hostname kerberos.test.h5l.se \
563 --hostname pal.test.h5l.se \
567 How to create a certificate for a user.
570 hxtool issue-certificate \
571 --type="pkinit-client" \
572 --pk-init-principal="user@@TEST.H5L.SE" \
576 @subsection XMPP/Jabber
578 The jabber server certificate should have a dNSname that is the same as
579 the user entered into the application, not the same as the host name of
583 hxtool issue-certificate \
584 --subject="CN=xmpp1.test.h5l.se,DC=test,DC=h5l,DC=se" \
585 --hostname="xmpp1.test.h5l.se" \
586 --hostname="test.h5l.se" \
590 The certificate may also contain a jabber identifier (JID) that, if the
591 receiver allows it, authorises the server or client to use that JID.
593 When storing a JID inside the certificate, both for server and client,
594 it's stored inside a UTF8String within an otherName entity inside the
595 subjectAltName, using the OID id-on-xmppAddr (1.3.6.1.5.5.7.8.5).
597 To read more about the requirements, see RFC3920, Extensible Messaging
598 and Presence Protocol (XMPP): Core.
600 hxtool issue-certificate have support to add jid to the certificate
601 using the option @kbd{--jid}.
604 hxtool issue-certificate \
605 --subject="CN=Love,DC=test,DC=h5l,DC=se" \
606 --jid="lha@@test.h5l.se" \
611 @node CMS signing and encryption, CMS background, Application requirements, Top
612 @chapter CMS signing and encryption
614 CMS is the Cryptographic Message System that among other, is used by
615 S/MIME (secure email) and Kerberos PK-INIT. It's an extended version of
616 the RSA, Inc standard PKCS7.
618 @node CMS background, Certificate matching, CMS signing and encryption, Top
619 @section CMS background
622 @node Certificate matching, Matching syntax, CMS background, Top
623 @chapter Certificate matching
625 To match certificates hx509 have a special query language to match
626 certifictes in queries and ACLs.
628 @node Matching syntax, Software PKCS 11 module, Certificate matching, Top
629 @section Matching syntax
631 This is the language definitions somewhat slopply descriped:
646 word IN ( word [, word ...])
647 word IN %@{variable.subvariable@}
655 @node Software PKCS 11 module, How to use the PKCS11 module, Matching syntax, Top
656 @chapter Software PKCS 11 module
658 PKCS11 is a standard created by RSA, Inc to support hardware and
659 software encryption modules. It can be used by smartcard to expose the
660 crypto primitives inside without exposing the crypto keys.
662 Hx509 includes a software implementation of PKCS11 that runs within the
663 memory space of the process and thus exposes the keys to the
666 @node How to use the PKCS11 module, , Software PKCS 11 module, Top
667 @section How to use the PKCS11 module
670 $ cat > ~/.soft-pkcs11.rc <<EOF
671 mycert cert User certificate FILE:/Users/lha/Private/pkinit.pem
674 $ kinit -C PKCS11:/usr/heimdal/lib/hx509.so lha@@EXAMPLE.ORG