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>]
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
63 The options descriptions will be divided into each purpose.
71 Print out a usage message.
75 This prints extra details about the operations being performed.
77 =item B<-config filename>
79 Specifies the configuration file to use.
80 Optional; for a description of the default value,
81 see L<openssl(1)/COMMAND SUMMARY>.
83 =item B<-name section>
85 Specifies the configuration file section to use (overrides
86 B<default_ca> in the B<ca> section).
90 An input filename containing a single certificate request to be
93 =item B<-ss_cert filename>
95 A single self-signed certificate to be signed by the CA.
97 =item B<-spkac filename>
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.
105 If present this should be the last option, all subsequent arguments
106 are taken as the names of files containing certificate requests.
108 =item B<-out filename>
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).
114 =item B<-outdir directory>
116 The directory to output certificates to. The certificate will be
117 written to a filename consisting of the serial number in hex with
122 The CA certificate file.
124 =item B<-keyfile filename>
126 The private key to sign requests with.
128 =item B<-keyform PEM|DER>
130 The format of the data in the private key file.
133 =item B<-key password>
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.
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
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.
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)>.
160 Don't output the text form of a certificate to the output file.
162 =item B<-startdate date>
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).
167 =item B<-enddate date>
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).
174 The number of days to certify the certificate for.
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.
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.
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.
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.
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.
215 This sets the batch mode. In this mode no questions will be asked
216 and all certificates will be certified automatically.
218 =item B<-extensions section>
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.
228 =item B<-extfile file>
230 An additional configuration file to read certificate extensions from
231 (using the default section unless the B<-extensions> option is also
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.
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.
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.
254 =item B<-create_serial>
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
260 =item B<-multivalue-rdn>
262 This option causes the -subj argument to be interpreted with full
263 support for multivalued RDNs. Example:
265 I</DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe>
267 If -multi-rdn is not used then the UID value is I<123456+CN=John Doe>.
277 This option generates a CRL based on information in the index file.
279 =item B<-crldays num>
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.
284 =item B<-crlhours num>
286 The number of hours before the next CRL is due.
288 =item B<-revoke filename>
290 A filename containing a certificate to revoke.
292 =item B<-valid filename>
294 A filename containing a certificate to add a Valid certificate entry.
296 =item B<-status serial>
298 Displays the revocation status of the certificate with the specified
299 serial number and exits.
303 Updates the database index to purge expired certificates.
305 =item B<-crl_reason reason>
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.
312 In practice B<removeFromCRL> is not particularly useful because it is only used
313 in delta CRLs which are not currently implemented.
315 =item B<-crl_hold instruction>
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.
322 =item B<-crl_compromise time>
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>.
327 =item B<-crl_CA_compromise time>
329 This is the same as B<crl_compromise> except the revocation reason is set to
332 =item B<-crlexts section>
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.
345 =head1 CONFIGURATION FILE OPTIONS
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:
357 With the exception of B<RANDFILE>, this is probably a bug and may
358 change in future releases.
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
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.
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.
383 =item B<new_certs_dir>
385 The same as the B<-outdir> command line option. It specifies
386 the directory where new certificates will be placed. Mandatory.
390 The same as B<-cert>. It gives the file containing the CA
391 certificate. Mandatory.
395 Same as the B<-keyfile> option. The file containing the
396 CA private key. Mandatory.
400 A file used to read and write random number seed information, or
401 an EGD socket (see L<RAND_egd(3)>).
403 =item B<default_days>
405 The same as the B<-days> option. The number of days to certify
408 =item B<default_startdate>
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.
413 =item B<default_enddate>
415 The same as the B<-enddate> option. Either this option or
416 B<default_days> (or the command line equivalents) must be
419 =item B<default_crl_hours default_crl_days>
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.
427 The same as the B<-md> option. Mandatory.
431 The text database file to use. Mandatory. This file must be present
432 though initially it will be empty.
434 =item B<unique_subject>
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.
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.
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.
455 =item B<x509_extensions>
457 The same as B<-extensions>.
459 =item B<crl_extensions>
461 The same as B<-crlexts>.
465 The same as B<-preserveDN>
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.
475 The same as B<-msie_hack>
479 The same as B<-policy>. Mandatory. See the B<POLICY FORMAT> section
480 for more information.
482 =item B<name_opt>, B<cert_opt>
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).
491 For convenience the values B<ca_default> are accepted by both to produce
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.
499 =item B<copy_extensions>
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
510 The main use of this option is to allow a certificate request to supply
511 values for certain extensions such as subjectAltName.
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.
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.
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 '.'.
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>
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.
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
557 Sign a certificate request:
559 openssl ca -in req.pem -out newcert.pem
561 Sign a certificate request, using CA extensions:
563 openssl ca -in req.pem -extensions v3_ca -out newcert.pem
567 openssl ca -gencrl -out crl.pem
569 Sign several requests:
571 openssl ca -infiles req1.pem req2.pem req3.pem
573 Certify a Netscape SPKAC:
575 openssl ca -spkac spkac.txt
577 A sample SPKAC file (the SPKAC line has been truncated for clarity):
579 SPKAC=MIG0MGAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAn7PDhCeV/xIxUg8V70YRxK2A5
581 emailAddress=steve@openssl.org
585 A sample configuration file with the relevant sections for B<ca>:
588 default_ca = CA_default # The default ca section
592 dir = ./demoCA # top dir
593 database = $dir/index.txt # index file.
594 new_certs_dir = $dir/newcerts # new certs dir
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
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
605 policy = policy_any # default policy
606 email_in_dn = no # Don't add the email into cert DN
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
613 countryName = supplied
614 stateOrProvinceName = optional
615 organizationName = optional
616 organizationalUnitName = optional
617 commonName = supplied
618 emailAddress = optional
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.
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
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.
644 V2 CRL features like delta CRLs are not currently supported.
646 Although several requests can be input and handled at once it is only
647 possible to include one SPKAC or self-signed certificate.
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.
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.
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
667 Canceling some commands by refusing to certify a certificate can
668 create an empty file.
672 The B<ca> command is quirky and at times downright unfriendly.
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.
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.
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.
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
694 It is advisable to also include values for other extensions such
695 as B<keyUsage> to prevent a request supplying its own values.
697 Additional restrictions can be placed on the CA certificate itself.
698 For example if the CA certificate has:
700 basicConstraints = CA:TRUE, pathlen:0
702 then even if a certificate is issued with CA:TRUE it will not be valid.
706 L<req(1)>, L<spkac(1)>, L<x509(1)>, L<CA.pl(1)>,
707 L<config(5)>, L<x509v3_config(5)>
711 Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved.
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>.