1CA(1)                               OpenSSL                              CA(1)
2
3
4

NAME

6       ca - sample minimal CA application
7

SYNOPSIS

9       openssl ca [-verbose] [-config filename] [-name section] [-gencrl]
10       [-revoke file] [-crl_reason reason] [-crl_hold instruction]
11       [-crl_compromise time] [-crl_CA_compromise time] [-crldays days]
12       [-crlhours hours] [-crlexts section] [-startdate date] [-enddate date]
13       [-days arg] [-md arg] [-policy arg] [-keyfile arg] [-key arg] [-passin
14       arg] [-cert file] [-selfsign] [-in file] [-out file] [-notext] [-outdir
15       dir] [-infiles] [-spkac file] [-ss_cert file] [-preserveDN]
16       [-noemailDN] [-batch] [-msie_hack] [-extensions section] [-extfile
17       section] [-engine id] [-subj arg] [-utf8] [-multivalue-rdn]
18

DESCRIPTION

20       The ca command is a minimal CA application. It can be used to sign
21       certificate requests in a variety of forms and generate CRLs it also
22       maintains a text database of issued certificates and their status.
23
24       The options descriptions will be divided into each purpose.
25

CA OPTIONS

27       -config filename
28           specifies the configuration file to use.
29
30       -name section
31           specifies the configuration file section to use (overrides
32           default_ca in the ca section).
33
34       -in filename
35           an input filename containing a single certificate request to be
36           signed by the CA.
37
38       -ss_cert filename
39           a single self signed certificate to be signed by the CA.
40
41       -spkac filename
42           a file containing a single Netscape signed public key and challenge
43           and additional field values to be signed by the CA. See the SPKAC
44           FORMAT section for information on the required format.
45
46       -infiles
47           if present this should be the last option, all subsequent arguments
48           are assumed to the the names of files containing certificate
49           requests.
50
51       -out filename
52           the output file to output certificates to. The default is standard
53           output. The certificate details will also be printed out to this
54           file.
55
56       -outdir directory
57           the directory to output certificates to. The certificate will be
58           written to a filename consisting of the serial number in hex with
59           ".pem" appended.
60
61       -cert
62           the CA certificate file.
63
64       -keyfile filename
65           the private key to sign requests with.
66
67       -key password
68           the password used to encrypt the private key. Since on some systems
69           the command line arguments are visible (e.g. Unix with the 'ps'
70           utility) this option should be used with caution.
71
72       -selfsign
73           indicates the issued certificates are to be signed with the key the
74           certificate requests were signed with (given with -keyfile).
75           Cerificate requests signed with a different key are ignored.  If
76           -spkac, -ss_cert or -gencrl are given, -selfsign is ignored.
77
78           A consequence of using -selfsign is that the self-signed
79           certificate appears among the entries in the certificate database
80           (see the configuration option database), and uses the same serial
81           number counter as all other certificates sign with the self-signed
82           certificate.
83
84       -passin arg
85           the key password source. For more information about the format of
86           arg see the PASS PHRASE ARGUMENTS section in openssl(1).
87
88       -verbose
89           this prints extra details about the operations being performed.
90
91       -notext
92           don't output the text form of a certificate to the output file.
93
94       -startdate date
95           this allows the start date to be explicitly set. The format of the
96           date is YYMMDDHHMMSSZ (the same as an ASN1 UTCTime structure).
97
98       -enddate date
99           this allows the expiry date to be explicitly set. The format of the
100           date is YYMMDDHHMMSSZ (the same as an ASN1 UTCTime structure).
101
102       -days arg
103           the number of days to certify the certificate for.
104
105       -md alg
106           the message digest to use. Possible values include md5, sha1 and
107           mdc2.  For full list of digests see openssl dgst -h output. This
108           option also applies to CRLs.
109
110       -policy arg
111           this option defines the CA "policy" to use. This is a section in
112           the configuration file which decides which fields should be
113           mandatory or match the CA certificate. Check out the POLICY FORMAT
114           section for more information.
115
116       -msie_hack
117           this is a legacy option to make ca work with very old versions of
118           the IE certificate enrollment control "certenr3". It used
119           UniversalStrings for almost everything. Since the old control has
120           various security bugs its use is strongly discouraged. The newer
121           control "Xenroll" does not need this option.
122
123       -preserveDN
124           Normally the DN order of a certificate is the same as the order of
125           the fields in the relevant policy section. When this option is set
126           the order is the same as the request. This is largely for
127           compatibility with the older IE enrollment control which would only
128           accept certificates if their DNs match the order of the request.
129           This is not needed for Xenroll.
130
131       -noemailDN
132           The DN of a certificate can contain the EMAIL field if present in
133           the request DN, however it is good policy just having the e-mail
134           set into the altName extension of the certificate. When this option
135           is set the EMAIL field is removed from the certificate' subject and
136           set only in the, eventually present, extensions. The email_in_dn
137           keyword can be used in the configuration file to enable this
138           behaviour.
139
140       -batch
141           this sets the batch mode. In this mode no questions will be asked
142           and all certificates will be certified automatically.
143
144       -extensions section
145           the section of the configuration file containing certificate
146           extensions to be added when a certificate is issued (defaults to
147           x509_extensions unless the -extfile option is used). If no
148           extension section is present then, a V1 certificate is created. If
149           the extension section is present (even if it is empty), then a V3
150           certificate is created. See the:w x509v3_config(5) manual page for
151           details of the extension section format.
152
153       -extfile file
154           an additional configuration file to read certificate extensions
155           from (using the default section unless the -extensions option is
156           also used).
157
158       -engine id
159           specifying an engine (by its unique id string) will cause ca to
160           attempt to obtain a functional reference to the specified engine,
161           thus initialising it if needed. The engine will then be set as the
162           default for all available algorithms.
163
164       -subj arg
165           supersedes subject name given in the request.  The arg must be
166           formatted as /type0=value0/type1=value1/type2=..., characters may
167           be escaped by \ (backslash), no spaces are skipped.
168
169       -utf8
170           this option causes field values to be interpreted as UTF8 strings,
171           by default they are interpreted as ASCII. This means that the field
172           values, whether prompted from a terminal or obtained from a
173           configuration file, must be valid UTF8 strings.
174
175       -multivalue-rdn
176           this option causes the -subj argument to be interpretedt with full
177           support for multivalued RDNs. Example:
178
179           /DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe
180
181           If -multi-rdn is not used then the UID value is 123456+CN=John Doe.
182

CRL OPTIONS

184       -gencrl
185           this option generates a CRL based on information in the index file.
186
187       -crldays num
188           the number of days before the next CRL is due. That is the days
189           from now to place in the CRL nextUpdate field.
190
191       -crlhours num
192           the number of hours before the next CRL is due.
193
194       -revoke filename
195           a filename containing a certificate to revoke.
196
197       -crl_reason reason
198           revocation reason, where reason is one of: unspecified,
199           keyCompromise, CACompromise, affiliationChanged, superseded,
200           cessationOfOperation, certificateHold or removeFromCRL. The
201           matching of reason is case insensitive. Setting any revocation
202           reason will make the CRL v2.
203
204           In practive removeFromCRL is not particularly useful because it is
205           only used in delta CRLs which are not currently implemented.
206
207       -crl_hold instruction
208           This sets the CRL revocation reason code to certificateHold and the
209           hold instruction to instruction which must be an OID. Although any
210           OID can be used only holdInstructionNone (the use of which is
211           discouraged by RFC2459) holdInstructionCallIssuer or
212           holdInstructionReject will normally be used.
213
214       -crl_compromise time
215           This sets the revocation reason to keyCompromise and the compromise
216           time to time. time should be in GeneralizedTime format that is
217           YYYYMMDDHHMMSSZ.
218
219       -crl_CA_compromise time
220           This is the same as crl_compromise except the revocation reason is
221           set to CACompromise.
222
223       -crlexts section
224           the section of the configuration file containing CRL extensions to
225           include. If no CRL extension section is present then a V1 CRL is
226           created, if the CRL extension section is present (even if it is
227           empty) then a V2 CRL is created. The CRL extensions specified are
228           CRL extensions and not CRL entry extensions.  It should be noted
229           that some software (for example Netscape) can't handle V2 CRLs. See
230           x509v3_config(5) manual page for details of the extension section
231           format.
232

CONFIGURATION FILE OPTIONS

234       The section of the configuration file containing options for ca is
235       found as follows: If the -name command line option is used, then it
236       names the section to be used. Otherwise the section to be used must be
237       named in the default_ca option of the ca section of the configuration
238       file (or in the default section of the configuration file). Besides
239       default_ca, the following options are read directly from the ca
240       section:
241        RANDFILE
242        preserve
243        msie_hack With the exception of RANDFILE, this is probably a bug and
244       may change in future releases.
245
246       Many of the configuration file options are identical to command line
247       options. Where the option is present in the configuration file and the
248       command line the command line value is used. Where an option is
249       described as mandatory then it must be present in the configuration
250       file or the command line equivalent (if any) used.
251
252       oid_file
253           This specifies a file containing additional OBJECT IDENTIFIERS.
254           Each line of the file should consist of the numerical form of the
255           object identifier followed by white space then the short name
256           followed by white space and finally the long name.
257
258       oid_section
259           This specifies a section in the configuration file containing extra
260           object identifiers. Each line should consist of the short name of
261           the object identifier followed by = and the numerical form. The
262           short and long names are the same when this option is used.
263
264       new_certs_dir
265           the same as the -outdir command line option. It specifies the
266           directory where new certificates will be placed. Mandatory.
267
268       certificate
269           the same as -cert. It gives the file containing the CA certificate.
270           Mandatory.
271
272       private_key
273           same as the -keyfile option. The file containing the CA private
274           key. Mandatory.
275
276       RANDFILE
277           a file used to read and write random number seed information, or an
278           EGD socket (see RAND_egd(3)).
279
280       default_days
281           the same as the -days option. The number of days to certify a
282           certificate for.
283
284       default_startdate
285           the same as the -startdate option. The start date to certify a
286           certificate for. If not set the current time is used.
287
288       default_enddate
289           the same as the -enddate option. Either this option or default_days
290           (or the command line equivalents) must be present.
291
292       default_crl_hours default_crl_days
293           the same as the -crlhours and the -crldays options. These will only
294           be used if neither command line option is present. At least one of
295           these must be present to generate a CRL.
296
297       default_md
298           the same as the -md option. The message digest to use. Mandatory.
299
300       database
301           the text database file to use. Mandatory. This file must be present
302           though initially it will be empty.
303
304       unique_subject
305           if the value yes is given, the valid certificate entries in the
306           database must have unique subjects.  if the value no is given,
307           several valid certificate entries may have the exact same subject.
308           The default value is yes, to be compatible with older (pre 0.9.8)
309           versions of OpenSSL.  However, to make CA certificate roll-over
310           easier, it's recommended to use the value no, especially if
311           combined with the -selfsign command line option.
312
313       serial
314           a text file containing the next serial number to use in hex.
315           Mandatory.  This file must be present and contain a valid serial
316           number.
317
318       crlnumber
319           a text file containing the next CRL number to use in hex. The crl
320           number will be inserted in the CRLs only if this file exists. If
321           this file is present, it must contain a valid CRL number.
322
323       x509_extensions
324           the same as -extensions.
325
326       crl_extensions
327           the same as -crlexts.
328
329       preserve
330           the same as -preserveDN
331
332       email_in_dn
333           the same as -noemailDN. If you want the EMAIL field to be removed
334           from the DN of the certificate simply set this to 'no'. If not
335           present the default is to allow for the EMAIL filed in the
336           certificate's DN.
337
338       msie_hack
339           the same as -msie_hack
340
341       policy
342           the same as -policy. Mandatory. See the POLICY FORMAT section for
343           more information.
344
345       name_opt, cert_opt
346           these options allow the format used to display the certificate
347           details when asking the user to confirm signing. All the options
348           supported by the x509 utilities -nameopt and -certopt switches can
349           be used here, except the no_signame and no_sigdump are permanently
350           set and cannot be disabled (this is because the certificate
351           signature cannot be displayed because the certificate has not been
352           signed at this point).
353
354           For convenience the values ca_default are accepted by both to
355           produce a reasonable output.
356
357           If neither option is present the format used in earlier versions of
358           OpenSSL is used. Use of the old format is strongly discouraged
359           because it only displays fields mentioned in the policy section,
360           mishandles multicharacter string types and does not display
361           extensions.
362
363       copy_extensions
364           determines how extensions in certificate requests should be
365           handled.  If set to none or this option is not present then
366           extensions are ignored and not copied to the certificate. If set to
367           copy then any extensions present in the request that are not
368           already present are copied to the certificate. If set to copyall
369           then all extensions in the request are copied to the certificate:
370           if the extension is already present in the certificate it is
371           deleted first. See the WARNINGS section before using this option.
372
373           The main use of this option is to allow a certificate request to
374           supply values for certain extensions such as subjectAltName.
375

POLICY FORMAT

377       The policy section consists of a set of variables corresponding to
378       certificate DN fields. If the value is "match" then the field value
379       must match the same field in the CA certificate. If the value is
380       "supplied" then it must be present. If the value is "optional" then it
381       may be present. Any fields not mentioned in the policy section are
382       silently deleted, unless the -preserveDN option is set but this can be
383       regarded more of a quirk than intended behaviour.
384

SPKAC FORMAT

386       The input to the -spkac command line option is a Netscape signed public
387       key and challenge. This will usually come from the KEYGEN tag in an
388       HTML form to create a new private key.  It is however possible to
389       create SPKACs using the spkac utility.
390
391       The file should contain the variable SPKAC set to the value of the
392       SPKAC and also the required DN components as name value pairs.  If you
393       need to include the same component twice then it can be preceded by a
394       number and a '.'.
395

EXAMPLES

397       Note: these examples assume that the ca directory structure is already
398       set up and the relevant files already exist. This usually involves
399       creating a CA certificate and private key with req, a serial number
400       file and an empty index file and placing them in the relevant
401       directories.
402
403       To use the sample configuration file below the directories demoCA,
404       demoCA/private and demoCA/newcerts would be created. The CA certificate
405       would be copied to demoCA/cacert.pem and its private key to
406       demoCA/private/cakey.pem. A file demoCA/serial would be created
407       containing for example "01" and the empty index file demoCA/index.txt.
408
409       Sign a certificate request:
410
411        openssl ca -in req.pem -out newcert.pem
412
413       Sign a certificate request, using CA extensions:
414
415        openssl ca -in req.pem -extensions v3_ca -out newcert.pem
416
417       Generate a CRL
418
419        openssl ca -gencrl -out crl.pem
420
421       Sign several requests:
422
423        openssl ca -infiles req1.pem req2.pem req3.pem
424
425       Certify a Netscape SPKAC:
426
427        openssl ca -spkac spkac.txt
428
429       A sample SPKAC file (the SPKAC line has been truncated for clarity):
430
431        SPKAC=MIG0MGAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAn7PDhCeV/xIxUg8V70YRxK2A5
432        CN=Steve Test
433        emailAddress=steve@openssl.org
434        0.OU=OpenSSL Group
435        1.OU=Another Group
436
437       A sample configuration file with the relevant sections for ca:
438
439        [ ca ]
440        default_ca      = CA_default            # The default ca section
441
442        [ CA_default ]
443
444        dir            = ./demoCA              # top dir
445        database       = $dir/index.txt        # index file.
446        new_certs_dir  = $dir/newcerts         # new certs dir
447
448        certificate    = $dir/cacert.pem       # The CA cert
449        serial         = $dir/serial           # serial no file
450        private_key    = $dir/private/cakey.pem# CA private key
451        RANDFILE       = $dir/private/.rand    # random number file
452
453        default_days   = 365                   # how long to certify for
454        default_crl_days= 30                   # how long before next CRL
455        default_md     = md5                   # md to use
456
457        policy         = policy_any            # default policy
458        email_in_dn    = no                    # Don't add the email into cert DN
459
460        name_opt       = ca_default            # Subject name display option
461        cert_opt       = ca_default            # Certificate display option
462        copy_extensions = none                 # Don't copy extensions from request
463
464        [ policy_any ]
465        countryName            = supplied
466        stateOrProvinceName    = optional
467        organizationName       = optional
468        organizationalUnitName = optional
469        commonName             = supplied
470        emailAddress           = optional
471

FILES

473       Note: the location of all files can change either by compile time
474       options, configuration file entries, environment variables or command
475       line options.  The values below reflect the default values.
476
477        /usr/local/ssl/lib/openssl.cnf - master configuration file
478        ./demoCA                       - main CA directory
479        ./demoCA/cacert.pem            - CA certificate
480        ./demoCA/private/cakey.pem     - CA private key
481        ./demoCA/serial                - CA serial number file
482        ./demoCA/serial.old            - CA serial number backup file
483        ./demoCA/index.txt             - CA text database file
484        ./demoCA/index.txt.old         - CA text database backup file
485        ./demoCA/certs                 - certificate output file
486        ./demoCA/.rnd                  - CA random seed information
487

ENVIRONMENT VARIABLES

489       OPENSSL_CONF reflects the location of master configuration file it can
490       be overridden by the -config command line option.
491

RESTRICTIONS

493       The text database index file is a critical part of the process and if
494       corrupted it can be difficult to fix. It is theoretically possible to
495       rebuild the index file from all the issued certificates and a current
496       CRL: however there is no option to do this.
497
498       V2 CRL features like delta CRLs are not currently supported.
499
500       Although several requests can be input and handled at once it is only
501       possible to include one SPKAC or self signed certificate.
502

BUGS

504       The use of an in memory text database can cause problems when large
505       numbers of certificates are present because, as the name implies the
506       database has to be kept in memory.
507
508       The ca command really needs rewriting or the required functionality
509       exposed at either a command or interface level so a more friendly
510       utility (perl script or GUI) can handle things properly. The scripts
511       CA.sh and CA.pl help a little but not very much.
512
513       Any fields in a request that are not present in a policy are silently
514       deleted. This does not happen if the -preserveDN option is used. To
515       enforce the absence of the EMAIL field within the DN, as suggested by
516       RFCs, regardless the contents of the request' subject the -noemailDN
517       option can be used. The behaviour should be more friendly and
518       configurable.
519
520       Cancelling some commands by refusing to certify a certificate can
521       create an empty file.
522

WARNINGS

524       The ca command is quirky and at times downright unfriendly.
525
526       The ca utility was originally meant as an example of how to do things
527       in a CA. It was not supposed to be used as a full blown CA itself:
528       nevertheless some people are using it for this purpose.
529
530       The ca command is effectively a single user command: no locking is done
531       on the various files and attempts to run more than one ca command on
532       the same database can have unpredictable results.
533
534       The copy_extensions option should be used with caution. If care is not
535       taken then it can be a security risk. For example if a certificate
536       request contains a basicConstraints extension with CA:TRUE and the
537       copy_extensions value is set to copyall and the user does not spot this
538       when the certificate is displayed then this will hand the requestor a
539       valid CA certificate.
540
541       This situation can be avoided by setting copy_extensions to copy and
542       including basicConstraints with CA:FALSE in the configuration file.
543       Then if the request contains a basicConstraints extension it will be
544       ignored.
545
546       It is advisable to also include values for other extensions such as
547       keyUsage to prevent a request supplying its own values.
548
549       Additional restrictions can be placed on the CA certificate itself.
550       For example if the CA certificate has:
551
552        basicConstraints = CA:TRUE, pathlen:0
553
554       then even if a certificate is issued with CA:TRUE it will not be valid.
555

SEE ALSO

557       req(1), spkac(1), x509(1), CA.pl(1), config(5), x509v3_config(5)
558
559
560
5611.0.1e                            2017-03-22                             CA(1)
Impressum