Various doc fixes
[openssl.git] / doc / man1 / ca.pod
1 =pod
2
3 =head1 NAME
4
5 ca - sample minimal CA application
6
7 =head1 SYNOPSIS
8
9 B<openssl> B<ca>
10 [B<-help>]
11 [B<-verbose>]
12 [B<-config filename>]
13 [B<-name section>]
14 [B<-gencrl>]
15 [B<-revoke file>]
16 [B<-valid file>]
17 [B<-status serial>]
18 [B<-updatedb>]
19 [B<-crl_reason reason>]
20 [B<-crl_hold instruction>]
21 [B<-crl_compromise time>]
22 [B<-crl_CA_compromise time>]
23 [B<-crldays days>]
24 [B<-crlhours hours>]
25 [B<-crlexts section>]
26 [B<-startdate date>]
27 [B<-enddate date>]
28 [B<-days arg>]
29 [B<-md arg>]
30 [B<-policy arg>]
31 [B<-keyfile arg>]
32 [B<-keyform PEM|DER>]
33 [B<-key arg>]
34 [B<-passin arg>]
35 [B<-cert file>]
36 [B<-selfsign>]
37 [B<-in file>]
38 [B<-out file>]
39 [B<-notext>]
40 [B<-outdir dir>]
41 [B<-infiles>]
42 [B<-spkac file>]
43 [B<-ss_cert file>]
44 [B<-preserveDN>]
45 [B<-noemailDN>]
46 [B<-batch>]
47 [B<-msie_hack>]
48 [B<-extensions section>]
49 [B<-extfile section>]
50 [B<-engine id>]
51 [B<-subj arg>]
52 [B<-utf8>]
53 [B<-create_serial>]
54 [B<-multivalue-rdn>]
55
56 =head1 DESCRIPTION
57
58 The B<ca> command is a minimal CA application. It can be used
59 to sign certificate requests in a variety of forms and generate
60 CRLs it also maintains a text database of issued certificates
61 and their status.
62
63 The options descriptions will be divided into each purpose.
64
65 =head1 OPTIONS
66
67 =over 4
68
69 =item B<-help>
70
71 Print out a usage message.
72
73 =item B<-verbose>
74
75 This prints extra details about the operations being performed.
76
77 =item B<-config filename>
78
79 Specifies the configuration file to use.
80 Optional; for a description of the default value,
81 see L<openssl(1)/COMMAND SUMMARY>.
82
83 =item B<-name section>
84
85 Specifies the configuration file section to use (overrides
86 B<default_ca> in the B<ca> section).
87
88 =item B<-in filename>
89
90 An input filename containing a single certificate request to be
91 signed by the CA.
92
93 =item B<-ss_cert filename>
94
95 A single self-signed certificate to be signed by the CA.
96
97 =item B<-spkac filename>
98
99 A file containing a single Netscape signed public key and challenge
100 and additional field values to be signed by the CA. See the B<SPKAC FORMAT>
101 section for information on the required input and output format.
102
103 =item B<-infiles>
104
105 If present this should be the last option, all subsequent arguments
106 are taken as the names of files containing certificate requests.
107
108 =item B<-out filename>
109
110 The output file to output certificates to. The default is standard
111 output. The certificate details will also be printed out to this
112 file in PEM format (except that B<-spkac> outputs DER format).
113
114 =item B<-outdir directory>
115
116 The directory to output certificates to. The certificate will be
117 written to a filename consisting of the serial number in hex with
118 ".pem" appended.
119
120 =item B<-cert>
121
122 The CA certificate file.
123
124 =item B<-keyfile filename>
125
126 The private key to sign requests with.
127
128 =item B<-keyform PEM|DER>
129
130 The format of the data in the private key file.
131 The default is PEM.
132
133 =item B<-key password>
134
135 The password used to encrypt the private key. Since on some
136 systems the command line arguments are visible (e.g. Unix with
137 the 'ps' utility) this option should be used with caution.
138
139 =item B<-selfsign>
140
141 Indicates the issued certificates are to be signed with the key
142 the certificate requests were signed with (given with B<-keyfile>).
143 Certificate requests signed with a different key are ignored.  If
144 B<-spkac>, B<-ss_cert> or B<-gencrl> are given, B<-selfsign> is
145 ignored.
146
147 A consequence of using B<-selfsign> is that the self-signed
148 certificate appears among the entries in the certificate database
149 (see the configuration option B<database>), and uses the same
150 serial number counter as all other certificates sign with the
151 self-signed certificate.
152
153 =item B<-passin arg>
154
155 The key password source. For more information about the format of B<arg>
156 see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>.
157
158 =item B<-notext>
159
160 Don't output the text form of a certificate to the output file.
161
162 =item B<-startdate date>
163
164 This allows the start date to be explicitly set. The format of the
165 date is YYMMDDHHMMSSZ (the same as an ASN1 UTCTime structure).
166
167 =item B<-enddate date>
168
169 This allows the expiry date to be explicitly set. The format of the
170 date is YYMMDDHHMMSSZ (the same as an ASN1 UTCTime structure).
171
172 =item B<-days arg>
173
174 The number of days to certify the certificate for.
175
176 =item B<-md alg>
177
178 The message digest to use.
179 Any digest supported by the OpenSSL B<dgst> command can be used.
180 This option also applies to CRLs.
181
182 =item B<-policy arg>
183
184 This option defines the CA "policy" to use. This is a section in
185 the configuration file which decides which fields should be mandatory
186 or match the CA certificate. Check out the B<POLICY FORMAT> section
187 for more information.
188
189 =item B<-msie_hack>
190
191 This is a deprecated option to make B<ca> work with very old versions of
192 the IE certificate enrollment control "certenr3". It used UniversalStrings
193 for almost everything. Since the old control has various security bugs
194 its use is strongly discouraged.
195
196 =item B<-preserveDN>
197
198 Normally the DN order of a certificate is the same as the order of the
199 fields in the relevant policy section. When this option is set the order
200 is the same as the request. This is largely for compatibility with the
201 older IE enrollment control which would only accept certificates if their
202 DNs match the order of the request. This is not needed for Xenroll.
203
204 =item B<-noemailDN>
205
206 The DN of a certificate can contain the EMAIL field if present in the
207 request DN, however it is good policy just having the e-mail set into
208 the altName extension of the certificate. When this option is set the
209 EMAIL field is removed from the certificate' subject and set only in
210 the, eventually present, extensions. The B<email_in_dn> keyword can be
211 used in the configuration file to enable this behaviour.
212
213 =item B<-batch>
214
215 This sets the batch mode. In this mode no questions will be asked
216 and all certificates will be certified automatically.
217
218 =item B<-extensions section>
219
220 The section of the configuration file containing certificate extensions
221 to be added when a certificate is issued (defaults to B<x509_extensions>
222 unless the B<-extfile> option is used). If no extension section is
223 present then, a V1 certificate is created. If the extension section
224 is present (even if it is empty), then a V3 certificate is created. See the:w
225 L<x509v3_config(5)> manual page for details of the
226 extension section format.
227
228 =item B<-extfile file>
229
230 An additional configuration file to read certificate extensions from
231 (using the default section unless the B<-extensions> option is also
232 used).
233
234 =item B<-engine id>
235
236 Specifying an engine (by its unique B<id> string) will cause B<ca>
237 to attempt to obtain a functional reference to the specified engine,
238 thus initialising it if needed. The engine will then be set as the default
239 for all available algorithms.
240
241 =item B<-subj arg>
242
243 Supersedes subject name given in the request.
244 The arg must be formatted as I</type0=value0/type1=value1/type2=...>,
245 characters may be escaped by \ (backslash), no spaces are skipped.
246
247 =item B<-utf8>
248
249 This option causes field values to be interpreted as UTF8 strings, by
250 default they are interpreted as ASCII. This means that the field
251 values, whether prompted from a terminal or obtained from a
252 configuration file, must be valid UTF8 strings.
253
254 =item B<-create_serial>
255
256 If reading serial from the text file as specified in the configuration
257 fails, specifying this option creates a new random serial to be used as next
258 serial number.
259
260 =item B<-multivalue-rdn>
261
262 This option causes the -subj argument to be interpreted with full
263 support for multivalued RDNs. Example:
264
265 I</DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe>
266
267 If -multi-rdn is not used then the UID value is I<123456+CN=John Doe>.
268
269 =back
270
271 =head1 CRL OPTIONS
272
273 =over 4
274
275 =item B<-gencrl>
276
277 This option generates a CRL based on information in the index file.
278
279 =item B<-crldays num>
280
281 The number of days before the next CRL is due. That is the days from
282 now to place in the CRL nextUpdate field.
283
284 =item B<-crlhours num>
285
286 The number of hours before the next CRL is due.
287
288 =item B<-revoke filename>
289
290 A filename containing a certificate to revoke.
291
292 =item B<-valid filename>
293
294 A filename containing a certificate to add a Valid certificate entry.
295
296 =item B<-status serial>
297
298 Displays the revocation status of the certificate with the specified
299 serial number and exits.
300
301 =item B<-updatedb>
302
303 Updates the database index to purge expired certificates.
304
305 =item B<-crl_reason reason>
306
307 Revocation reason, where B<reason> is one of: B<unspecified>, B<keyCompromise>,
308 B<CACompromise>, B<affiliationChanged>, B<superseded>, B<cessationOfOperation>,
309 B<certificateHold> or B<removeFromCRL>. The matching of B<reason> is case
310 insensitive. Setting any revocation reason will make the CRL v2.
311
312 In practice B<removeFromCRL> is not particularly useful because it is only used
313 in delta CRLs which are not currently implemented.
314
315 =item B<-crl_hold instruction>
316
317 This sets the CRL revocation reason code to B<certificateHold> and the hold
318 instruction to B<instruction> which must be an OID. Although any OID can be
319 used only B<holdInstructionNone> (the use of which is discouraged by RFC2459)
320 B<holdInstructionCallIssuer> or B<holdInstructionReject> will normally be used.
321
322 =item B<-crl_compromise time>
323
324 This sets the revocation reason to B<keyCompromise> and the compromise time to
325 B<time>. B<time> should be in GeneralizedTime format that is B<YYYYMMDDHHMMSSZ>.
326
327 =item B<-crl_CA_compromise time>
328
329 This is the same as B<crl_compromise> except the revocation reason is set to
330 B<CACompromise>.
331
332 =item B<-crlexts section>
333
334 The section of the configuration file containing CRL extensions to
335 include. If no CRL extension section is present then a V1 CRL is
336 created, if the CRL extension section is present (even if it is
337 empty) then a V2 CRL is created. The CRL extensions specified are
338 CRL extensions and B<not> CRL entry extensions.  It should be noted
339 that some software (for example Netscape) can't handle V2 CRLs. See
340 L<x509v3_config(5)> manual page for details of the
341 extension section format.
342
343 =back
344
345 =head1 CONFIGURATION FILE OPTIONS
346
347 The section of the configuration file containing options for B<ca>
348 is found as follows: If the B<-name> command line option is used,
349 then it names the section to be used. Otherwise the section to
350 be used must be named in the B<default_ca> option of the B<ca> section
351 of the configuration file (or in the default section of the
352 configuration file). Besides B<default_ca>, the following options are
353 read directly from the B<ca> section:
354  RANDFILE
355  preserve
356  msie_hack
357 With the exception of B<RANDFILE>, this is probably a bug and may
358 change in future releases.
359
360 Many of the configuration file options are identical to command line
361 options. Where the option is present in the configuration file
362 and the command line the command line value is used. Where an
363 option is described as mandatory then it must be present in
364 the configuration file or the command line equivalent (if
365 any) used.
366
367 =over 4
368
369 =item B<oid_file>
370
371 This specifies a file containing additional B<OBJECT IDENTIFIERS>.
372 Each line of the file should consist of the numerical form of the
373 object identifier followed by white space then the short name followed
374 by white space and finally the long name.
375
376 =item B<oid_section>
377
378 This specifies a section in the configuration file containing extra
379 object identifiers. Each line should consist of the short name of the
380 object identifier followed by B<=> and the numerical form. The short
381 and long names are the same when this option is used.
382
383 =item B<new_certs_dir>
384
385 The same as the B<-outdir> command line option. It specifies
386 the directory where new certificates will be placed. Mandatory.
387
388 =item B<certificate>
389
390 The same as B<-cert>. It gives the file containing the CA
391 certificate. Mandatory.
392
393 =item B<private_key>
394
395 Same as the B<-keyfile> option. The file containing the
396 CA private key. Mandatory.
397
398 =item B<RANDFILE>
399
400 A file used to read and write random number seed information, or
401 an EGD socket (see L<RAND_egd(3)>).
402
403 =item B<default_days>
404
405 The same as the B<-days> option. The number of days to certify
406 a certificate for.
407
408 =item B<default_startdate>
409
410 The same as the B<-startdate> option. The start date to certify
411 a certificate for. If not set the current time is used.
412
413 =item B<default_enddate>
414
415 The same as the B<-enddate> option. Either this option or
416 B<default_days> (or the command line equivalents) must be
417 present.
418
419 =item B<default_crl_hours default_crl_days>
420
421 The same as the B<-crlhours> and the B<-crldays> options. These
422 will only be used if neither command line option is present. At
423 least one of these must be present to generate a CRL.
424
425 =item B<default_md>
426
427 The same as the B<-md> option. Mandatory.
428
429 =item B<database>
430
431 The text database file to use. Mandatory. This file must be present
432 though initially it will be empty.
433
434 =item B<unique_subject>
435
436 If the value B<yes> is given, the valid certificate entries in the
437 database must have unique subjects.  if the value B<no> is given,
438 several valid certificate entries may have the exact same subject.
439 The default value is B<yes>, to be compatible with older (pre 0.9.8)
440 versions of OpenSSL.  However, to make CA certificate roll-over easier,
441 it's recommended to use the value B<no>, especially if combined with
442 the B<-selfsign> command line option.
443
444 =item B<serial>
445
446 A text file containing the next serial number to use in hex. Mandatory.
447 This file must be present and contain a valid serial number.
448
449 =item B<crlnumber>
450
451 A text file containing the next CRL number to use in hex. The crl number
452 will be inserted in the CRLs only if this file exists. If this file is
453 present, it must contain a valid CRL number.
454
455 =item B<x509_extensions>
456
457 The same as B<-extensions>.
458
459 =item B<crl_extensions>
460
461 The same as B<-crlexts>.
462
463 =item B<preserve>
464
465 The same as B<-preserveDN>
466
467 =item B<email_in_dn>
468
469 The same as B<-noemailDN>. If you want the EMAIL field to be removed
470 from the DN of the certificate simply set this to 'no'. If not present
471 the default is to allow for the EMAIL filed in the certificate's DN.
472
473 =item B<msie_hack>
474
475 The same as B<-msie_hack>
476
477 =item B<policy>
478
479 The same as B<-policy>. Mandatory. See the B<POLICY FORMAT> section
480 for more information.
481
482 =item B<name_opt>, B<cert_opt>
483
484 These options allow the format used to display the certificate details
485 when asking the user to confirm signing. All the options supported by
486 the B<x509> utilities B<-nameopt> and B<-certopt> switches can be used
487 here, except the B<no_signame> and B<no_sigdump> are permanently set
488 and cannot be disabled (this is because the certificate signature cannot
489 be displayed because the certificate has not been signed at this point).
490
491 For convenience the values B<ca_default> are accepted by both to produce
492 a reasonable output.
493
494 If neither option is present the format used in earlier versions of
495 OpenSSL is used. Use of the old format is B<strongly> discouraged because
496 it only displays fields mentioned in the B<policy> section, mishandles
497 multicharacter string types and does not display extensions.
498
499 =item B<copy_extensions>
500
501 Determines how extensions in certificate requests should be handled.
502 If set to B<none> or this option is not present then extensions are
503 ignored and not copied to the certificate. If set to B<copy> then any
504 extensions present in the request that are not already present are copied
505 to the certificate. If set to B<copyall> then all extensions in the
506 request are copied to the certificate: if the extension is already present
507 in the certificate it is deleted first. See the B<WARNINGS> section before
508 using this option.
509
510 The main use of this option is to allow a certificate request to supply
511 values for certain extensions such as subjectAltName.
512
513 =back
514
515 =head1 POLICY FORMAT
516
517 The policy section consists of a set of variables corresponding to
518 certificate DN fields. If the value is "match" then the field value
519 must match the same field in the CA certificate. If the value is
520 "supplied" then it must be present. If the value is "optional" then
521 it may be present. Any fields not mentioned in the policy section
522 are silently deleted, unless the B<-preserveDN> option is set but
523 this can be regarded more of a quirk than intended behaviour.
524
525 =head1 SPKAC FORMAT
526
527 The input to the B<-spkac> command line option is a Netscape
528 signed public key and challenge. This will usually come from
529 the B<KEYGEN> tag in an HTML form to create a new private key.
530 It is however possible to create SPKACs using the B<spkac> utility.
531
532 The file should contain the variable SPKAC set to the value of
533 the SPKAC and also the required DN components as name value pairs.
534 If you need to include the same component twice then it can be
535 preceded by a number and a '.'.
536
537 When processing SPKAC format, the output is DER if the B<-out>
538 flag is used, but PEM format if sending to stdout or the B<-outdir>
539 flag is used.
540
541 =head1 EXAMPLES
542
543 Note: these examples assume that the B<ca> directory structure is
544 already set up and the relevant files already exist. This usually
545 involves creating a CA certificate and private key with B<req>, a
546 serial number file and an empty index file and placing them in
547 the relevant directories.
548
549 To use the sample configuration file below the directories demoCA,
550 demoCA/private and demoCA/newcerts would be created. The CA
551 certificate would be copied to demoCA/cacert.pem and its private
552 key to demoCA/private/cakey.pem. A file demoCA/serial would be
553 created containing for example "01" and the empty index file
554 demoCA/index.txt.
555
556
557 Sign a certificate request:
558
559  openssl ca -in req.pem -out newcert.pem
560
561 Sign a certificate request, using CA extensions:
562
563  openssl ca -in req.pem -extensions v3_ca -out newcert.pem
564
565 Generate a CRL
566
567  openssl ca -gencrl -out crl.pem
568
569 Sign several requests:
570
571  openssl ca -infiles req1.pem req2.pem req3.pem
572
573 Certify a Netscape SPKAC:
574
575  openssl ca -spkac spkac.txt
576
577 A sample SPKAC file (the SPKAC line has been truncated for clarity):
578
579  SPKAC=MIG0MGAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAn7PDhCeV/xIxUg8V70YRxK2A5
580  CN=Steve Test
581  emailAddress=steve@openssl.org
582  0.OU=OpenSSL Group
583  1.OU=Another Group
584
585 A sample configuration file with the relevant sections for B<ca>:
586
587  [ ca ]
588  default_ca      = CA_default            # The default ca section
589
590  [ CA_default ]
591
592  dir            = ./demoCA              # top dir
593  database       = $dir/index.txt        # index file.
594  new_certs_dir  = $dir/newcerts         # new certs dir
595
596  certificate    = $dir/cacert.pem       # The CA cert
597  serial         = $dir/serial           # serial no file
598  private_key    = $dir/private/cakey.pem# CA private key
599  RANDFILE       = $dir/private/.rand    # random number file
600
601  default_days   = 365                   # how long to certify for
602  default_crl_days= 30                   # how long before next CRL
603  default_md     = md5                   # md to use
604
605  policy         = policy_any            # default policy
606  email_in_dn    = no                    # Don't add the email into cert DN
607
608  name_opt       = ca_default            # Subject name display option
609  cert_opt       = ca_default            # Certificate display option
610  copy_extensions = none                 # Don't copy extensions from request
611
612  [ policy_any ]
613  countryName            = supplied
614  stateOrProvinceName    = optional
615  organizationName       = optional
616  organizationalUnitName = optional
617  commonName             = supplied
618  emailAddress           = optional
619
620 =head1 FILES
621
622 Note: the location of all files can change either by compile time options,
623 configuration file entries, environment variables or command line options.
624 The values below reflect the default values.
625
626  /usr/local/ssl/lib/openssl.cnf - master configuration file
627  ./demoCA                       - main CA directory
628  ./demoCA/cacert.pem            - CA certificate
629  ./demoCA/private/cakey.pem     - CA private key
630  ./demoCA/serial                - CA serial number file
631  ./demoCA/serial.old            - CA serial number backup file
632  ./demoCA/index.txt             - CA text database file
633  ./demoCA/index.txt.old         - CA text database backup file
634  ./demoCA/certs                 - certificate output file
635  ./demoCA/.rnd                  - CA random seed information
636
637 =head1 RESTRICTIONS
638
639 The text database index file is a critical part of the process and
640 if corrupted it can be difficult to fix. It is theoretically possible
641 to rebuild the index file from all the issued certificates and a current
642 CRL: however there is no option to do this.
643
644 V2 CRL features like delta CRLs are not currently supported.
645
646 Although several requests can be input and handled at once it is only
647 possible to include one SPKAC or self-signed certificate.
648
649 =head1 BUGS
650
651 The use of an in-memory text database can cause problems when large
652 numbers of certificates are present because, as the name implies
653 the database has to be kept in memory.
654
655 The B<ca> command really needs rewriting or the required functionality
656 exposed at either a command or interface level so a more friendly utility
657 (perl script or GUI) can handle things properly. The script
658 B<CA.pl> helps a little but not very much.
659
660 Any fields in a request that are not present in a policy are silently
661 deleted. This does not happen if the B<-preserveDN> option is used. To
662 enforce the absence of the EMAIL field within the DN, as suggested by
663 RFCs, regardless the contents of the request' subject the B<-noemailDN>
664 option can be used. The behaviour should be more friendly and
665 configurable.
666
667 Canceling some commands by refusing to certify a certificate can
668 create an empty file.
669
670 =head1 WARNINGS
671
672 The B<ca> command is quirky and at times downright unfriendly.
673
674 The B<ca> utility was originally meant as an example of how to do things
675 in a CA. It was not supposed to be used as a full blown CA itself:
676 nevertheless some people are using it for this purpose.
677
678 The B<ca> command is effectively a single user command: no locking is
679 done on the various files and attempts to run more than one B<ca> command
680 on the same database can have unpredictable results.
681
682 The B<copy_extensions> option should be used with caution. If care is
683 not taken then it can be a security risk. For example if a certificate
684 request contains a basicConstraints extension with CA:TRUE and the
685 B<copy_extensions> value is set to B<copyall> and the user does not spot
686 this when the certificate is displayed then this will hand the requester
687 a valid CA certificate.
688
689 This situation can be avoided by setting B<copy_extensions> to B<copy>
690 and including basicConstraints with CA:FALSE in the configuration file.
691 Then if the request contains a basicConstraints extension it will be
692 ignored.
693
694 It is advisable to also include values for other extensions such
695 as B<keyUsage> to prevent a request supplying its own values.
696
697 Additional restrictions can be placed on the CA certificate itself.
698 For example if the CA certificate has:
699
700  basicConstraints = CA:TRUE, pathlen:0
701
702 then even if a certificate is issued with CA:TRUE it will not be valid.
703
704 =head1 SEE ALSO
705
706 L<req(1)>, L<spkac(1)>, L<x509(1)>, L<CA.pl(1)>,
707 L<config(5)>, L<x509v3_config(5)>
708
709 =head1 COPYRIGHT
710
711 Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved.
712
713 Licensed under the OpenSSL license (the "License").  You may not use
714 this file except in compliance with the License.  You can obtain a copy
715 in the file LICENSE in the source distribution or at
716 L<https://www.openssl.org/source/license.html>.
717
718 =cut