5 ca - sample minimal CA application
19 [B<-crl_reason reason>]
20 [B<-crl_hold instruction>]
21 [B<-crl_compromise time>]
22 [B<-crl_CA_compromise time>]
48 [B<-extensions section>]
61 The B<ca> command is a minimal CA application. It can be used
62 to sign certificate requests in a variety of forms and generate
63 CRLs it also maintains a text database of issued certificates
66 The options descriptions will be divided into each purpose.
74 Print out a usage message.
78 This prints extra details about the operations being performed.
80 =item B<-config filename>
82 Specifies the configuration file to use.
83 Optional; for a description of the default value,
84 see L<openssl(1)/COMMAND SUMMARY>.
86 =item B<-name section>
88 Specifies the configuration file section to use (overrides
89 B<default_ca> in the B<ca> section).
93 An input filename containing a single certificate request to be
96 =item B<-ss_cert filename>
98 A single self-signed certificate to be signed by the CA.
100 =item B<-spkac filename>
102 A file containing a single Netscape signed public key and challenge
103 and additional field values to be signed by the CA. See the B<SPKAC FORMAT>
104 section for information on the required input and output format.
108 If present this should be the last option, all subsequent arguments
109 are taken as the names of files containing certificate requests.
111 =item B<-out filename>
113 The output file to output certificates to. The default is standard
114 output. The certificate details will also be printed out to this
115 file in PEM format (except that B<-spkac> outputs DER format).
117 =item B<-outdir directory>
119 The directory to output certificates to. The certificate will be
120 written to a filename consisting of the serial number in hex with
125 The CA certificate file.
127 =item B<-keyfile filename>
129 The private key to sign requests with.
131 =item B<-keyform PEM|DER>
133 The format of the data in the private key file.
136 =item B<-key password>
138 The password used to encrypt the private key. Since on some
139 systems the command line arguments are visible (e.g. Unix with
140 the 'ps' utility) this option should be used with caution.
144 Indicates the issued certificates are to be signed with the key
145 the certificate requests were signed with (given with B<-keyfile>).
146 Certificate requests signed with a different key are ignored. If
147 B<-spkac>, B<-ss_cert> or B<-gencrl> are given, B<-selfsign> is
150 A consequence of using B<-selfsign> is that the self-signed
151 certificate appears among the entries in the certificate database
152 (see the configuration option B<database>), and uses the same
153 serial number counter as all other certificates sign with the
154 self-signed certificate.
158 The key password source. For more information about the format of B<arg>
159 see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>.
163 Don't output the text form of a certificate to the output file.
165 =item B<-startdate date>
167 This allows the start date to be explicitly set. The format of the
168 date is YYMMDDHHMMSSZ (the same as an ASN1 UTCTime structure), or
169 YYYYMMDDHHMMSSZ (the same as an ASN1 GeneralizedTime structure). In
170 both formats, seconds SS and timezone Z must be present.
172 =item B<-enddate date>
174 This allows the expiry date to be explicitly set. The format of the
175 date is YYMMDDHHMMSSZ (the same as an ASN1 UTCTime structure), or
176 YYYYMMDDHHMMSSZ (the same as an ASN1 GeneralizedTime structure). In
177 both formats, seconds SS and timezone Z must be present.
181 The number of days to certify the certificate for.
185 The message digest to use.
186 Any digest supported by the OpenSSL B<dgst> command can be used.
187 This option also applies to CRLs.
191 This option defines the CA "policy" to use. This is a section in
192 the configuration file which decides which fields should be mandatory
193 or match the CA certificate. Check out the B<POLICY FORMAT> section
194 for more information.
198 This is a deprecated option to make B<ca> work with very old versions of
199 the IE certificate enrollment control "certenr3". It used UniversalStrings
200 for almost everything. Since the old control has various security bugs
201 its use is strongly discouraged.
205 Normally the DN order of a certificate is the same as the order of the
206 fields in the relevant policy section. When this option is set the order
207 is the same as the request. This is largely for compatibility with the
208 older IE enrollment control which would only accept certificates if their
209 DNs match the order of the request. This is not needed for Xenroll.
213 The DN of a certificate can contain the EMAIL field if present in the
214 request DN, however it is good policy just having the e-mail set into
215 the altName extension of the certificate. When this option is set the
216 EMAIL field is removed from the certificate' subject and set only in
217 the, eventually present, extensions. The B<email_in_dn> keyword can be
218 used in the configuration file to enable this behaviour.
222 This sets the batch mode. In this mode no questions will be asked
223 and all certificates will be certified automatically.
225 =item B<-extensions section>
227 The section of the configuration file containing certificate extensions
228 to be added when a certificate is issued (defaults to B<x509_extensions>
229 unless the B<-extfile> option is used). If no extension section is
230 present then, a V1 certificate is created. If the extension section
231 is present (even if it is empty), then a V3 certificate is created. See the:w
232 L<x509v3_config(5)> manual page for details of the
233 extension section format.
235 =item B<-extfile file>
237 An additional configuration file to read certificate extensions from
238 (using the default section unless the B<-extensions> option is also
243 Specifying an engine (by its unique B<id> string) will cause B<ca>
244 to attempt to obtain a functional reference to the specified engine,
245 thus initialising it if needed. The engine will then be set as the default
246 for all available algorithms.
250 Supersedes subject name given in the request.
251 The arg must be formatted as I</type0=value0/type1=value1/type2=...>,
252 characters may be escaped by \ (backslash), no spaces are skipped.
256 This option causes field values to be interpreted as UTF8 strings, by
257 default they are interpreted as ASCII. This means that the field
258 values, whether prompted from a terminal or obtained from a
259 configuration file, must be valid UTF8 strings.
261 =item B<-create_serial>
263 If reading serial from the text file as specified in the configuration
264 fails, specifying this option creates a new random serial to be used as next
266 To get random serial numbers, use the B<-rand_serial> flag instead; this
267 should only be used for simple error-recovery.
269 =item B<-rand_serial>
271 Generate a large random number to use as the serial number.
272 This overrides any option or configuration to use a serial number file.
274 =item B<-multivalue-rdn>
276 This option causes the -subj argument to be interpreted with full
277 support for multivalued RDNs. Example:
279 I</DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe>
281 If -multi-rdn is not used then the UID value is I<123456+CN=John Doe>.
283 =item B<-rand file...>
285 A file or files containing random data used to seed the random number
287 Multiple files can be specified separated by an OS-dependent character.
288 The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
291 =item [B<-writerand file>]
293 Writes random data to the specified I<file> upon exit.
294 This can be used with a subsequent B<-rand> flag.
304 This option generates a CRL based on information in the index file.
306 =item B<-crldays num>
308 The number of days before the next CRL is due. That is the days from
309 now to place in the CRL nextUpdate field.
311 =item B<-crlhours num>
313 The number of hours before the next CRL is due.
315 =item B<-revoke filename>
317 A filename containing a certificate to revoke.
319 =item B<-valid filename>
321 A filename containing a certificate to add a Valid certificate entry.
323 =item B<-status serial>
325 Displays the revocation status of the certificate with the specified
326 serial number and exits.
330 Updates the database index to purge expired certificates.
332 =item B<-crl_reason reason>
334 Revocation reason, where B<reason> is one of: B<unspecified>, B<keyCompromise>,
335 B<CACompromise>, B<affiliationChanged>, B<superseded>, B<cessationOfOperation>,
336 B<certificateHold> or B<removeFromCRL>. The matching of B<reason> is case
337 insensitive. Setting any revocation reason will make the CRL v2.
339 In practice B<removeFromCRL> is not particularly useful because it is only used
340 in delta CRLs which are not currently implemented.
342 =item B<-crl_hold instruction>
344 This sets the CRL revocation reason code to B<certificateHold> and the hold
345 instruction to B<instruction> which must be an OID. Although any OID can be
346 used only B<holdInstructionNone> (the use of which is discouraged by RFC2459)
347 B<holdInstructionCallIssuer> or B<holdInstructionReject> will normally be used.
349 =item B<-crl_compromise time>
351 This sets the revocation reason to B<keyCompromise> and the compromise time to
352 B<time>. B<time> should be in GeneralizedTime format that is B<YYYYMMDDHHMMSSZ>.
354 =item B<-crl_CA_compromise time>
356 This is the same as B<crl_compromise> except the revocation reason is set to
359 =item B<-crlexts section>
361 The section of the configuration file containing CRL extensions to
362 include. If no CRL extension section is present then a V1 CRL is
363 created, if the CRL extension section is present (even if it is
364 empty) then a V2 CRL is created. The CRL extensions specified are
365 CRL extensions and B<not> CRL entry extensions. It should be noted
366 that some software (for example Netscape) can't handle V2 CRLs. See
367 L<x509v3_config(5)> manual page for details of the
368 extension section format.
372 =head1 CONFIGURATION FILE OPTIONS
374 The section of the configuration file containing options for B<ca>
375 is found as follows: If the B<-name> command line option is used,
376 then it names the section to be used. Otherwise the section to
377 be used must be named in the B<default_ca> option of the B<ca> section
378 of the configuration file (or in the default section of the
379 configuration file). Besides B<default_ca>, the following options are
380 read directly from the B<ca> section:
384 With the exception of B<RANDFILE>, this is probably a bug and may
385 change in future releases.
387 Many of the configuration file options are identical to command line
388 options. Where the option is present in the configuration file
389 and the command line the command line value is used. Where an
390 option is described as mandatory then it must be present in
391 the configuration file or the command line equivalent (if
398 This specifies a file containing additional B<OBJECT IDENTIFIERS>.
399 Each line of the file should consist of the numerical form of the
400 object identifier followed by white space then the short name followed
401 by white space and finally the long name.
405 This specifies a section in the configuration file containing extra
406 object identifiers. Each line should consist of the short name of the
407 object identifier followed by B<=> and the numerical form. The short
408 and long names are the same when this option is used.
410 =item B<new_certs_dir>
412 The same as the B<-outdir> command line option. It specifies
413 the directory where new certificates will be placed. Mandatory.
417 The same as B<-cert>. It gives the file containing the CA
418 certificate. Mandatory.
422 Same as the B<-keyfile> option. The file containing the
423 CA private key. Mandatory.
427 At startup the specified file is loaded into the random number generator,
428 and at exit 256 bytes will be written to it.
430 =item B<default_days>
432 The same as the B<-days> option. The number of days to certify
435 =item B<default_startdate>
437 The same as the B<-startdate> option. The start date to certify
438 a certificate for. If not set the current time is used.
440 =item B<default_enddate>
442 The same as the B<-enddate> option. Either this option or
443 B<default_days> (or the command line equivalents) must be
446 =item B<default_crl_hours default_crl_days>
448 The same as the B<-crlhours> and the B<-crldays> options. These
449 will only be used if neither command line option is present. At
450 least one of these must be present to generate a CRL.
454 The same as the B<-md> option. Mandatory.
458 The text database file to use. Mandatory. This file must be present
459 though initially it will be empty.
461 =item B<unique_subject>
463 If the value B<yes> is given, the valid certificate entries in the
464 database must have unique subjects. if the value B<no> is given,
465 several valid certificate entries may have the exact same subject.
466 The default value is B<yes>, to be compatible with older (pre 0.9.8)
467 versions of OpenSSL. However, to make CA certificate roll-over easier,
468 it's recommended to use the value B<no>, especially if combined with
469 the B<-selfsign> command line option.
473 A text file containing the next serial number to use in hex. Mandatory.
474 This file must be present and contain a valid serial number.
478 A text file containing the next CRL number to use in hex. The crl number
479 will be inserted in the CRLs only if this file exists. If this file is
480 present, it must contain a valid CRL number.
482 =item B<x509_extensions>
484 The same as B<-extensions>.
486 =item B<crl_extensions>
488 The same as B<-crlexts>.
492 The same as B<-preserveDN>
496 The same as B<-noemailDN>. If you want the EMAIL field to be removed
497 from the DN of the certificate simply set this to 'no'. If not present
498 the default is to allow for the EMAIL filed in the certificate's DN.
502 The same as B<-msie_hack>
506 The same as B<-policy>. Mandatory. See the B<POLICY FORMAT> section
507 for more information.
509 =item B<name_opt>, B<cert_opt>
511 These options allow the format used to display the certificate details
512 when asking the user to confirm signing. All the options supported by
513 the B<x509> utilities B<-nameopt> and B<-certopt> switches can be used
514 here, except the B<no_signame> and B<no_sigdump> are permanently set
515 and cannot be disabled (this is because the certificate signature cannot
516 be displayed because the certificate has not been signed at this point).
518 For convenience the values B<ca_default> are accepted by both to produce
521 If neither option is present the format used in earlier versions of
522 OpenSSL is used. Use of the old format is B<strongly> discouraged because
523 it only displays fields mentioned in the B<policy> section, mishandles
524 multicharacter string types and does not display extensions.
526 =item B<copy_extensions>
528 Determines how extensions in certificate requests should be handled.
529 If set to B<none> or this option is not present then extensions are
530 ignored and not copied to the certificate. If set to B<copy> then any
531 extensions present in the request that are not already present are copied
532 to the certificate. If set to B<copyall> then all extensions in the
533 request are copied to the certificate: if the extension is already present
534 in the certificate it is deleted first. See the B<WARNINGS> section before
537 The main use of this option is to allow a certificate request to supply
538 values for certain extensions such as subjectAltName.
544 The policy section consists of a set of variables corresponding to
545 certificate DN fields. If the value is "match" then the field value
546 must match the same field in the CA certificate. If the value is
547 "supplied" then it must be present. If the value is "optional" then
548 it may be present. Any fields not mentioned in the policy section
549 are silently deleted, unless the B<-preserveDN> option is set but
550 this can be regarded more of a quirk than intended behaviour.
554 The input to the B<-spkac> command line option is a Netscape
555 signed public key and challenge. This will usually come from
556 the B<KEYGEN> tag in an HTML form to create a new private key.
557 It is however possible to create SPKACs using the B<spkac> utility.
559 The file should contain the variable SPKAC set to the value of
560 the SPKAC and also the required DN components as name value pairs.
561 If you need to include the same component twice then it can be
562 preceded by a number and a '.'.
564 When processing SPKAC format, the output is DER if the B<-out>
565 flag is used, but PEM format if sending to stdout or the B<-outdir>
570 Note: these examples assume that the B<ca> directory structure is
571 already set up and the relevant files already exist. This usually
572 involves creating a CA certificate and private key with B<req>, a
573 serial number file and an empty index file and placing them in
574 the relevant directories.
576 To use the sample configuration file below the directories demoCA,
577 demoCA/private and demoCA/newcerts would be created. The CA
578 certificate would be copied to demoCA/cacert.pem and its private
579 key to demoCA/private/cakey.pem. A file demoCA/serial would be
580 created containing for example "01" and the empty index file
584 Sign a certificate request:
586 openssl ca -in req.pem -out newcert.pem
588 Sign a certificate request, using CA extensions:
590 openssl ca -in req.pem -extensions v3_ca -out newcert.pem
594 openssl ca -gencrl -out crl.pem
596 Sign several requests:
598 openssl ca -infiles req1.pem req2.pem req3.pem
600 Certify a Netscape SPKAC:
602 openssl ca -spkac spkac.txt
604 A sample SPKAC file (the SPKAC line has been truncated for clarity):
606 SPKAC=MIG0MGAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAn7PDhCeV/xIxUg8V70YRxK2A5
608 emailAddress=steve@openssl.org
612 A sample configuration file with the relevant sections for B<ca>:
615 default_ca = CA_default # The default ca section
619 dir = ./demoCA # top dir
620 database = $dir/index.txt # index file.
621 new_certs_dir = $dir/newcerts # new certs dir
623 certificate = $dir/cacert.pem # The CA cert
624 serial = $dir/serial # serial no file
625 #rand_serial = yes # for random serial#'s
626 private_key = $dir/private/cakey.pem# CA private key
627 RANDFILE = $dir/private/.rand # random number file
629 default_days = 365 # how long to certify for
630 default_crl_days= 30 # how long before next CRL
631 default_md = md5 # md to use
633 policy = policy_any # default policy
634 email_in_dn = no # Don't add the email into cert DN
636 name_opt = ca_default # Subject name display option
637 cert_opt = ca_default # Certificate display option
638 copy_extensions = none # Don't copy extensions from request
641 countryName = supplied
642 stateOrProvinceName = optional
643 organizationName = optional
644 organizationalUnitName = optional
645 commonName = supplied
646 emailAddress = optional
650 Note: the location of all files can change either by compile time options,
651 configuration file entries, environment variables or command line options.
652 The values below reflect the default values.
654 /usr/local/ssl/lib/openssl.cnf - master configuration file
655 ./demoCA - main CA directory
656 ./demoCA/cacert.pem - CA certificate
657 ./demoCA/private/cakey.pem - CA private key
658 ./demoCA/serial - CA serial number file
659 ./demoCA/serial.old - CA serial number backup file
660 ./demoCA/index.txt - CA text database file
661 ./demoCA/index.txt.old - CA text database backup file
662 ./demoCA/certs - certificate output file
663 ./demoCA/.rnd - CA random seed information
667 The text database index file is a critical part of the process and
668 if corrupted it can be difficult to fix. It is theoretically possible
669 to rebuild the index file from all the issued certificates and a current
670 CRL: however there is no option to do this.
672 V2 CRL features like delta CRLs are not currently supported.
674 Although several requests can be input and handled at once it is only
675 possible to include one SPKAC or self-signed certificate.
679 The use of an in-memory text database can cause problems when large
680 numbers of certificates are present because, as the name implies
681 the database has to be kept in memory.
683 The B<ca> command really needs rewriting or the required functionality
684 exposed at either a command or interface level so a more friendly utility
685 (perl script or GUI) can handle things properly. The script
686 B<CA.pl> helps a little but not very much.
688 Any fields in a request that are not present in a policy are silently
689 deleted. This does not happen if the B<-preserveDN> option is used. To
690 enforce the absence of the EMAIL field within the DN, as suggested by
691 RFCs, regardless the contents of the request' subject the B<-noemailDN>
692 option can be used. The behaviour should be more friendly and
695 Canceling some commands by refusing to certify a certificate can
696 create an empty file.
700 The B<ca> command is quirky and at times downright unfriendly.
702 The B<ca> utility was originally meant as an example of how to do things
703 in a CA. It was not supposed to be used as a full blown CA itself:
704 nevertheless some people are using it for this purpose.
706 The B<ca> command is effectively a single user command: no locking is
707 done on the various files and attempts to run more than one B<ca> command
708 on the same database can have unpredictable results.
710 The B<copy_extensions> option should be used with caution. If care is
711 not taken then it can be a security risk. For example if a certificate
712 request contains a basicConstraints extension with CA:TRUE and the
713 B<copy_extensions> value is set to B<copyall> and the user does not spot
714 this when the certificate is displayed then this will hand the requester
715 a valid CA certificate.
717 This situation can be avoided by setting B<copy_extensions> to B<copy>
718 and including basicConstraints with CA:FALSE in the configuration file.
719 Then if the request contains a basicConstraints extension it will be
722 It is advisable to also include values for other extensions such
723 as B<keyUsage> to prevent a request supplying its own values.
725 Additional restrictions can be placed on the CA certificate itself.
726 For example if the CA certificate has:
728 basicConstraints = CA:TRUE, pathlen:0
730 then even if a certificate is issued with CA:TRUE it will not be valid.
734 Since OpenSSL 1.1.1, the program follows RFC5280. Specifically,
735 certificate validity period (specified by any of B<-startdate>,
736 B<-enddate> and B<-days>) will be encoded as UTCTime if the dates are
737 earlier than year 2049 (included), and as GeneralizedTime if the dates
738 are in year 2050 or later.
742 L<req(1)>, L<spkac(1)>, L<x509(1)>, L<CA.pl(1)>,
743 L<config(5)>, L<x509v3_config(5)>
747 Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved.
749 Licensed under the OpenSSL license (the "License"). You may not use
750 this file except in compliance with the License. You can obtain a copy
751 in the file LICENSE in the source distribution or at
752 L<https://www.openssl.org/source/license.html>.