]>
Commit | Line | Data |
---|---|---|
aba3e65f DSH |
1 | =pod |
2 | ||
3 | =head1 NAME | |
4 | ||
5 | ca - sample minimal CA application | |
6 | ||
7 | =head1 SYNOPSIS | |
8 | ||
9 | B<openssl> B<ca> | |
169394d4 | 10 | [B<-help>] |
aba3e65f DSH |
11 | [B<-verbose>] |
12 | [B<-config filename>] | |
13 | [B<-name section>] | |
14 | [B<-gencrl>] | |
15 | [B<-revoke file>] | |
b4b42ce6 | 16 | [B<-valid file>] |
fc1d88f0 RS |
17 | [B<-status serial>] |
18 | [B<-updatedb>] | |
d618f703 DSH |
19 | [B<-crl_reason reason>] |
20 | [B<-crl_hold instruction>] | |
21 | [B<-crl_compromise time>] | |
22 | [B<-crl_CA_compromise time>] | |
aba3e65f DSH |
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>] | |
fc1d88f0 | 32 | [B<-keyform PEM|DER>] |
aba3e65f | 33 | [B<-key arg>] |
bd08a2bd | 34 | [B<-passin arg>] |
aba3e65f | 35 | [B<-cert file>] |
d6df2b28 | 36 | [B<-selfsign>] |
aba3e65f DSH |
37 | [B<-in file>] |
38 | [B<-out file>] | |
82fc1d9c | 39 | [B<-notext>] |
aba3e65f DSH |
40 | [B<-outdir dir>] |
41 | [B<-infiles>] | |
42 | [B<-spkac file>] | |
43 | [B<-ss_cert file>] | |
44 | [B<-preserveDN>] | |
89da653f | 45 | [B<-noemailDN>] |
aba3e65f DSH |
46 | [B<-batch>] |
47 | [B<-msie_hack>] | |
48 | [B<-extensions section>] | |
dfebac32 | 49 | [B<-extfile section>] |
bfa35550 | 50 | [B<-engine id>] |
57eb1d32 NL |
51 | [B<-subj arg>] |
52 | [B<-utf8>] | |
6755ff11 | 53 | [B<-create_serial>] |
ffb46830 | 54 | [B<-rand_serial>] |
57eb1d32 | 55 | [B<-multivalue-rdn>] |
3ee1eac2 RS |
56 | [B<-rand file...>] |
57 | [B<-writerand file>] | |
aba3e65f DSH |
58 | |
59 | =head1 DESCRIPTION | |
60 | ||
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 | |
64 | and their status. | |
65 | ||
66 | The options descriptions will be divided into each purpose. | |
67 | ||
3dfda1a6 | 68 | =head1 OPTIONS |
aba3e65f DSH |
69 | |
70 | =over 4 | |
71 | ||
6755ff11 MR |
72 | =item B<-help> |
73 | ||
74 | Print out a usage message. | |
75 | ||
76 | =item B<-verbose> | |
77 | ||
c4de074e | 78 | This prints extra details about the operations being performed. |
6755ff11 | 79 | |
aba3e65f DSH |
80 | =item B<-config filename> |
81 | ||
c4de074e | 82 | Specifies the configuration file to use. |
e9681f83 RS |
83 | Optional; for a description of the default value, |
84 | see L<openssl(1)/COMMAND SUMMARY>. | |
aba3e65f | 85 | |
8a0a9392 BM |
86 | =item B<-name section> |
87 | ||
c4de074e | 88 | Specifies the configuration file section to use (overrides |
8a0a9392 BM |
89 | B<default_ca> in the B<ca> section). |
90 | ||
aba3e65f DSH |
91 | =item B<-in filename> |
92 | ||
c4de074e | 93 | An input filename containing a single certificate request to be |
aba3e65f DSH |
94 | signed by the CA. |
95 | ||
96 | =item B<-ss_cert filename> | |
97 | ||
c4de074e | 98 | A single self-signed certificate to be signed by the CA. |
aba3e65f DSH |
99 | |
100 | =item B<-spkac filename> | |
101 | ||
c4de074e | 102 | A file containing a single Netscape signed public key and challenge |
d618f703 | 103 | and additional field values to be signed by the CA. See the B<SPKAC FORMAT> |
fc1d88f0 | 104 | section for information on the required input and output format. |
aba3e65f DSH |
105 | |
106 | =item B<-infiles> | |
107 | ||
c4de074e | 108 | If present this should be the last option, all subsequent arguments |
1bc74519 | 109 | are taken as the names of files containing certificate requests. |
aba3e65f DSH |
110 | |
111 | =item B<-out filename> | |
112 | ||
c4de074e | 113 | The output file to output certificates to. The default is standard |
aba3e65f | 114 | output. The certificate details will also be printed out to this |
fc1d88f0 | 115 | file in PEM format (except that B<-spkac> outputs DER format). |
aba3e65f DSH |
116 | |
117 | =item B<-outdir directory> | |
118 | ||
c4de074e | 119 | The directory to output certificates to. The certificate will be |
aba3e65f DSH |
120 | written to a filename consisting of the serial number in hex with |
121 | ".pem" appended. | |
122 | ||
123 | =item B<-cert> | |
124 | ||
c4de074e | 125 | The CA certificate file. |
aba3e65f DSH |
126 | |
127 | =item B<-keyfile filename> | |
128 | ||
c4de074e | 129 | The private key to sign requests with. |
aba3e65f | 130 | |
fc1d88f0 RS |
131 | =item B<-keyform PEM|DER> |
132 | ||
c4de074e | 133 | The format of the data in the private key file. |
fc1d88f0 RS |
134 | The default is PEM. |
135 | ||
aba3e65f DSH |
136 | =item B<-key password> |
137 | ||
c4de074e | 138 | The password used to encrypt the private key. Since on some |
aba3e65f DSH |
139 | systems the command line arguments are visible (e.g. Unix with |
140 | the 'ps' utility) this option should be used with caution. | |
141 | ||
d6df2b28 RL |
142 | =item B<-selfsign> |
143 | ||
c4de074e | 144 | Indicates the issued certificates are to be signed with the key |
d6df2b28 | 145 | the certificate requests were signed with (given with B<-keyfile>). |
42b91f28 | 146 | Certificate requests signed with a different key are ignored. If |
d6df2b28 RL |
147 | B<-spkac>, B<-ss_cert> or B<-gencrl> are given, B<-selfsign> is |
148 | ignored. | |
149 | ||
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. | |
155 | ||
bd08a2bd DSH |
156 | =item B<-passin arg> |
157 | ||
c4de074e | 158 | The key password source. For more information about the format of B<arg> |
9b86974e | 159 | see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)>. |
bad40585 | 160 | |
82fc1d9c DSH |
161 | =item B<-notext> |
162 | ||
c4de074e | 163 | Don't output the text form of a certificate to the output file. |
82fc1d9c | 164 | |
aba3e65f DSH |
165 | =item B<-startdate date> |
166 | ||
c4de074e | 167 | This allows the start date to be explicitly set. The format of the |
909873bd PY |
168 | date is YYMMDDHHMMSSZ (the same as an ASN1 UTCTime structure), or |
169 | YYYYMMDDHHMMSSZ (the same as an ASN1 GeneralizedTime structure). In | |
a970b14f | 170 | both formats, seconds SS and timezone Z must be present. |
aba3e65f DSH |
171 | |
172 | =item B<-enddate date> | |
173 | ||
c4de074e | 174 | This allows the expiry date to be explicitly set. The format of the |
909873bd PY |
175 | date is YYMMDDHHMMSSZ (the same as an ASN1 UTCTime structure), or |
176 | YYYYMMDDHHMMSSZ (the same as an ASN1 GeneralizedTime structure). In | |
a970b14f | 177 | both formats, seconds SS and timezone Z must be present. |
aba3e65f DSH |
178 | |
179 | =item B<-days arg> | |
180 | ||
c4de074e | 181 | The number of days to certify the certificate for. |
aba3e65f DSH |
182 | |
183 | =item B<-md alg> | |
184 | ||
c4de074e | 185 | The message digest to use. |
c03726ca | 186 | Any digest supported by the OpenSSL B<dgst> command can be used. |
aba3e65f DSH |
187 | This option also applies to CRLs. |
188 | ||
189 | =item B<-policy arg> | |
190 | ||
c4de074e | 191 | This option defines the CA "policy" to use. This is a section in |
aba3e65f DSH |
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. | |
195 | ||
196 | =item B<-msie_hack> | |
197 | ||
a95d7574 | 198 | This is a deprecated option to make B<ca> work with very old versions of |
aba3e65f DSH |
199 | the IE certificate enrollment control "certenr3". It used UniversalStrings |
200 | for almost everything. Since the old control has various security bugs | |
a95d7574 | 201 | its use is strongly discouraged. |
aba3e65f DSH |
202 | |
203 | =item B<-preserveDN> | |
204 | ||
53b1899e | 205 | Normally the DN order of a certificate is the same as the order of the |
1bc74519 | 206 | fields in the relevant policy section. When this option is set the order |
19d2bb57 | 207 | is the same as the request. This is largely for compatibility with the |
53b1899e DSH |
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. | |
aba3e65f | 210 | |
89da653f BM |
211 | =item B<-noemailDN> |
212 | ||
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. | |
219 | ||
aba3e65f DSH |
220 | =item B<-batch> |
221 | ||
c4de074e | 222 | This sets the batch mode. In this mode no questions will be asked |
aba3e65f DSH |
223 | and all certificates will be certified automatically. |
224 | ||
225 | =item B<-extensions section> | |
226 | ||
c4de074e | 227 | The section of the configuration file containing certificate extensions |
dfebac32 BM |
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 | |
137de5b1 | 231 | is present (even if it is empty), then a V3 certificate is created. See the:w |
9b86974e | 232 | L<x509v3_config(5)> manual page for details of the |
137de5b1 | 233 | extension section format. |
dfebac32 BM |
234 | |
235 | =item B<-extfile file> | |
236 | ||
c4de074e | 237 | An additional configuration file to read certificate extensions from |
dfebac32 BM |
238 | (using the default section unless the B<-extensions> option is also |
239 | used). | |
aba3e65f | 240 | |
bfa35550 RL |
241 | =item B<-engine id> |
242 | ||
c4de074e | 243 | Specifying an engine (by its unique B<id> string) will cause B<ca> |
bfa35550 RL |
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. | |
247 | ||
57eb1d32 NL |
248 | =item B<-subj arg> |
249 | ||
c4de074e | 250 | Supersedes subject name given in the request. |
57eb1d32 NL |
251 | The arg must be formatted as I</type0=value0/type1=value1/type2=...>, |
252 | characters may be escaped by \ (backslash), no spaces are skipped. | |
253 | ||
254 | =item B<-utf8> | |
255 | ||
c4de074e | 256 | This option causes field values to be interpreted as UTF8 strings, by |
57eb1d32 NL |
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. | |
260 | ||
6755ff11 MR |
261 | =item B<-create_serial> |
262 | ||
c4de074e | 263 | If reading serial from the text file as specified in the configuration |
6755ff11 MR |
264 | fails, specifying this option creates a new random serial to be used as next |
265 | serial number. | |
ffb46830 RS |
266 | To get random serial numbers, use the B<-rand_serial> flag instead; this |
267 | should only be used for simple error-recovery. | |
268 | ||
269 | =item B<-rand_serial> | |
270 | ||
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. | |
6755ff11 | 273 | |
57eb1d32 NL |
274 | =item B<-multivalue-rdn> |
275 | ||
4c583c36 | 276 | This option causes the -subj argument to be interpreted with full |
57eb1d32 NL |
277 | support for multivalued RDNs. Example: |
278 | ||
279 | I</DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe> | |
280 | ||
281 | If -multi-rdn is not used then the UID value is I<123456+CN=John Doe>. | |
282 | ||
3ee1eac2 RS |
283 | =item B<-rand file...> |
284 | ||
285 | A file or files containing random data used to seed the random number | |
286 | generator. | |
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 | |
289 | all others. | |
290 | ||
291 | =item [B<-writerand file>] | |
292 | ||
293 | Writes random data to the specified I<file> upon exit. | |
294 | This can be used with a subsequent B<-rand> flag. | |
295 | ||
aba3e65f DSH |
296 | =back |
297 | ||
298 | =head1 CRL OPTIONS | |
299 | ||
300 | =over 4 | |
301 | ||
302 | =item B<-gencrl> | |
303 | ||
c4de074e | 304 | This option generates a CRL based on information in the index file. |
aba3e65f DSH |
305 | |
306 | =item B<-crldays num> | |
307 | ||
c4de074e | 308 | The number of days before the next CRL is due. That is the days from |
aba3e65f DSH |
309 | now to place in the CRL nextUpdate field. |
310 | ||
311 | =item B<-crlhours num> | |
312 | ||
c4de074e | 313 | The number of hours before the next CRL is due. |
aba3e65f DSH |
314 | |
315 | =item B<-revoke filename> | |
316 | ||
c4de074e | 317 | A filename containing a certificate to revoke. |
aba3e65f | 318 | |
b4b42ce6 F |
319 | =item B<-valid filename> |
320 | ||
c4de074e | 321 | A filename containing a certificate to add a Valid certificate entry. |
b4b42ce6 | 322 | |
fc1d88f0 RS |
323 | =item B<-status serial> |
324 | ||
c4de074e | 325 | Displays the revocation status of the certificate with the specified |
fc1d88f0 RS |
326 | serial number and exits. |
327 | ||
328 | =item B<-updatedb> | |
329 | ||
330 | Updates the database index to purge expired certificates. | |
331 | ||
d618f703 DSH |
332 | =item B<-crl_reason reason> |
333 | ||
c4de074e | 334 | Revocation reason, where B<reason> is one of: B<unspecified>, B<keyCompromise>, |
d618f703 DSH |
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. | |
338 | ||
42b91f28 | 339 | In practice B<removeFromCRL> is not particularly useful because it is only used |
d618f703 DSH |
340 | in delta CRLs which are not currently implemented. |
341 | ||
342 | =item B<-crl_hold instruction> | |
343 | ||
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. | |
348 | ||
349 | =item B<-crl_compromise time> | |
350 | ||
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>. | |
353 | ||
354 | =item B<-crl_CA_compromise time> | |
355 | ||
356 | This is the same as B<crl_compromise> except the revocation reason is set to | |
357 | B<CACompromise>. | |
358 | ||
aba3e65f DSH |
359 | =item B<-crlexts section> |
360 | ||
c4de074e | 361 | The section of the configuration file containing CRL extensions to |
aba3e65f DSH |
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 | |
137de5b1 | 366 | that some software (for example Netscape) can't handle V2 CRLs. See |
9b86974e | 367 | L<x509v3_config(5)> manual page for details of the |
137de5b1 | 368 | extension section format. |
aba3e65f DSH |
369 | |
370 | =back | |
371 | ||
372 | =head1 CONFIGURATION FILE OPTIONS | |
373 | ||
8a0a9392 BM |
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: | |
381 | RANDFILE | |
382 | preserve | |
383 | msie_hack | |
384 | With the exception of B<RANDFILE>, this is probably a bug and may | |
385 | change in future releases. | |
386 | ||
387 | Many of the configuration file options are identical to command line | |
aba3e65f DSH |
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 | |
392 | any) used. | |
393 | ||
394 | =over 4 | |
395 | ||
5e76807b DSH |
396 | =item B<oid_file> |
397 | ||
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 | |
1bc74519 | 401 | by white space and finally the long name. |
5e76807b DSH |
402 | |
403 | =item B<oid_section> | |
404 | ||
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. | |
409 | ||
aba3e65f DSH |
410 | =item B<new_certs_dir> |
411 | ||
c4de074e | 412 | The same as the B<-outdir> command line option. It specifies |
aba3e65f DSH |
413 | the directory where new certificates will be placed. Mandatory. |
414 | ||
415 | =item B<certificate> | |
416 | ||
c4de074e | 417 | The same as B<-cert>. It gives the file containing the CA |
aba3e65f DSH |
418 | certificate. Mandatory. |
419 | ||
420 | =item B<private_key> | |
421 | ||
c4de074e | 422 | Same as the B<-keyfile> option. The file containing the |
aba3e65f DSH |
423 | CA private key. Mandatory. |
424 | ||
425 | =item B<RANDFILE> | |
426 | ||
3ee1eac2 RS |
427 | At startup the specified file is loaded into the random number generator, |
428 | and at exit 256 bytes will be written to it. | |
aba3e65f DSH |
429 | |
430 | =item B<default_days> | |
431 | ||
c4de074e | 432 | The same as the B<-days> option. The number of days to certify |
1bc74519 | 433 | a certificate for. |
aba3e65f DSH |
434 | |
435 | =item B<default_startdate> | |
436 | ||
c4de074e | 437 | The same as the B<-startdate> option. The start date to certify |
aba3e65f DSH |
438 | a certificate for. If not set the current time is used. |
439 | ||
440 | =item B<default_enddate> | |
441 | ||
c4de074e | 442 | The same as the B<-enddate> option. Either this option or |
aba3e65f DSH |
443 | B<default_days> (or the command line equivalents) must be |
444 | present. | |
445 | ||
446 | =item B<default_crl_hours default_crl_days> | |
447 | ||
c4de074e | 448 | The same as the B<-crlhours> and the B<-crldays> options. These |
aba3e65f DSH |
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. | |
451 | ||
452 | =item B<default_md> | |
453 | ||
c4de074e | 454 | The same as the B<-md> option. Mandatory. |
aba3e65f DSH |
455 | |
456 | =item B<database> | |
457 | ||
c4de074e | 458 | The text database file to use. Mandatory. This file must be present |
aba3e65f DSH |
459 | though initially it will be empty. |
460 | ||
d6df2b28 RL |
461 | =item B<unique_subject> |
462 | ||
c4de074e | 463 | If the value B<yes> is given, the valid certificate entries in the |
d6df2b28 RL |
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. | |
470 | ||
c5aba56c | 471 | =item B<serial> |
aba3e65f | 472 | |
c4de074e | 473 | A text file containing the next serial number to use in hex. Mandatory. |
aba3e65f DSH |
474 | This file must be present and contain a valid serial number. |
475 | ||
8fbb2af3 RL |
476 | =item B<crlnumber> |
477 | ||
c4de074e | 478 | A text file containing the next CRL number to use in hex. The crl number |
8fbb2af3 RL |
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. | |
481 | ||
aba3e65f DSH |
482 | =item B<x509_extensions> |
483 | ||
c4de074e | 484 | The same as B<-extensions>. |
aba3e65f DSH |
485 | |
486 | =item B<crl_extensions> | |
487 | ||
c4de074e | 488 | The same as B<-crlexts>. |
aba3e65f DSH |
489 | |
490 | =item B<preserve> | |
491 | ||
c4de074e | 492 | The same as B<-preserveDN> |
aba3e65f | 493 | |
89da653f BM |
494 | =item B<email_in_dn> |
495 | ||
c4de074e | 496 | The same as B<-noemailDN>. If you want the EMAIL field to be removed |
89da653f BM |
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. | |
499 | ||
aba3e65f DSH |
500 | =item B<msie_hack> |
501 | ||
c4de074e | 502 | The same as B<-msie_hack> |
aba3e65f DSH |
503 | |
504 | =item B<policy> | |
505 | ||
c4de074e | 506 | The same as B<-policy>. Mandatory. See the B<POLICY FORMAT> section |
aba3e65f DSH |
507 | for more information. |
508 | ||
b325518f | 509 | =item B<name_opt>, B<cert_opt> |
e890dcdb | 510 | |
c4de074e | 511 | These options allow the format used to display the certificate details |
e890dcdb DSH |
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). | |
517 | ||
6f2f534b | 518 | For convenience the values B<ca_default> are accepted by both to produce |
e890dcdb DSH |
519 | a reasonable output. |
520 | ||
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. | |
525 | ||
791bd0cd DSH |
526 | =item B<copy_extensions> |
527 | ||
c4de074e | 528 | Determines how extensions in certificate requests should be handled. |
791bd0cd DSH |
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 | |
535 | using this option. | |
536 | ||
537 | The main use of this option is to allow a certificate request to supply | |
538 | values for certain extensions such as subjectAltName. | |
539 | ||
aba3e65f DSH |
540 | =back |
541 | ||
542 | =head1 POLICY FORMAT | |
543 | ||
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. | |
551 | ||
552 | =head1 SPKAC FORMAT | |
553 | ||
554 | The input to the B<-spkac> command line option is a Netscape | |
555 | signed public key and challenge. This will usually come from | |
1bc74519 | 556 | the B<KEYGEN> tag in an HTML form to create a new private key. |
aba3e65f DSH |
557 | It is however possible to create SPKACs using the B<spkac> utility. |
558 | ||
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 '.'. | |
563 | ||
fc1d88f0 RS |
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> | |
566 | flag is used. | |
567 | ||
aba3e65f DSH |
568 | =head1 EXAMPLES |
569 | ||
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. | |
575 | ||
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 | |
581 | demoCA/index.txt. | |
582 | ||
583 | ||
584 | Sign a certificate request: | |
585 | ||
1675f6eb | 586 | openssl ca -in req.pem -out newcert.pem |
aba3e65f | 587 | |
d428bf8c DSH |
588 | Sign a certificate request, using CA extensions: |
589 | ||
590 | openssl ca -in req.pem -extensions v3_ca -out newcert.pem | |
591 | ||
aba3e65f DSH |
592 | Generate a CRL |
593 | ||
1675f6eb | 594 | openssl ca -gencrl -out crl.pem |
aba3e65f DSH |
595 | |
596 | Sign several requests: | |
597 | ||
1675f6eb | 598 | openssl ca -infiles req1.pem req2.pem req3.pem |
aba3e65f DSH |
599 | |
600 | Certify a Netscape SPKAC: | |
601 | ||
1675f6eb | 602 | openssl ca -spkac spkac.txt |
aba3e65f DSH |
603 | |
604 | A sample SPKAC file (the SPKAC line has been truncated for clarity): | |
605 | ||
606 | SPKAC=MIG0MGAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAn7PDhCeV/xIxUg8V70YRxK2A5 | |
607 | CN=Steve Test | |
608 | emailAddress=steve@openssl.org | |
609 | 0.OU=OpenSSL Group | |
610 | 1.OU=Another Group | |
611 | ||
612 | A sample configuration file with the relevant sections for B<ca>: | |
613 | ||
614 | [ ca ] | |
615 | default_ca = CA_default # The default ca section | |
1bc74519 | 616 | |
aba3e65f DSH |
617 | [ CA_default ] |
618 | ||
619 | dir = ./demoCA # top dir | |
620 | database = $dir/index.txt # index file. | |
1bc74519 RS |
621 | new_certs_dir = $dir/newcerts # new certs dir |
622 | ||
aba3e65f DSH |
623 | certificate = $dir/cacert.pem # The CA cert |
624 | serial = $dir/serial # serial no file | |
ffb46830 | 625 | #rand_serial = yes # for random serial#'s |
aba3e65f DSH |
626 | private_key = $dir/private/cakey.pem# CA private key |
627 | RANDFILE = $dir/private/.rand # random number file | |
1bc74519 | 628 | |
aba3e65f DSH |
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 | |
632 | ||
633 | policy = policy_any # default policy | |
89da653f | 634 | email_in_dn = no # Don't add the email into cert DN |
aba3e65f | 635 | |
1bc74519 RS |
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 | |
e890dcdb | 639 | |
aba3e65f DSH |
640 | [ policy_any ] |
641 | countryName = supplied | |
642 | stateOrProvinceName = optional | |
643 | organizationName = optional | |
644 | organizationalUnitName = optional | |
645 | commonName = supplied | |
646 | emailAddress = optional | |
647 | ||
aba3e65f DSH |
648 | =head1 FILES |
649 | ||
650 | Note: the location of all files can change either by compile time options, | |
19d2bb57 | 651 | configuration file entries, environment variables or command line options. |
aba3e65f DSH |
652 | The values below reflect the default values. |
653 | ||
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 | |
664 | ||
aba3e65f DSH |
665 | =head1 RESTRICTIONS |
666 | ||
1bc74519 | 667 | The text database index file is a critical part of the process and |
aba3e65f DSH |
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. | |
671 | ||
cb26a20c | 672 | V2 CRL features like delta CRLs are not currently supported. |
aba3e65f DSH |
673 | |
674 | Although several requests can be input and handled at once it is only | |
77a795e4 | 675 | possible to include one SPKAC or self-signed certificate. |
aba3e65f DSH |
676 | |
677 | =head1 BUGS | |
678 | ||
77a795e4 | 679 | The use of an in-memory text database can cause problems when large |
aba3e65f DSH |
680 | numbers of certificates are present because, as the name implies |
681 | the database has to be kept in memory. | |
682 | ||
aba3e65f DSH |
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 | |
be739b0c RS |
685 | (perl script or GUI) can handle things properly. The script |
686 | B<CA.pl> helps a little but not very much. | |
aba3e65f DSH |
687 | |
688 | Any fields in a request that are not present in a policy are silently | |
89da653f BM |
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 | |
693 | configurable. | |
aba3e65f | 694 | |
42b91f28 | 695 | Canceling some commands by refusing to certify a certificate can |
aba3e65f DSH |
696 | create an empty file. |
697 | ||
791bd0cd DSH |
698 | =head1 WARNINGS |
699 | ||
1f309464 LJ |
700 | The B<ca> command is quirky and at times downright unfriendly. |
701 | ||
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. | |
705 | ||
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. | |
709 | ||
791bd0cd DSH |
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 | |
42b91f28 | 714 | this when the certificate is displayed then this will hand the requester |
791bd0cd DSH |
715 | a valid CA certificate. |
716 | ||
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 | |
720 | ignored. | |
721 | ||
722 | It is advisable to also include values for other extensions such | |
723 | as B<keyUsage> to prevent a request supplying its own values. | |
724 | ||
725 | Additional restrictions can be placed on the CA certificate itself. | |
726 | For example if the CA certificate has: | |
727 | ||
728 | basicConstraints = CA:TRUE, pathlen:0 | |
729 | ||
730 | then even if a certificate is issued with CA:TRUE it will not be valid. | |
731 | ||
909873bd PY |
732 | =head1 HISTORY |
733 | ||
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. | |
739 | ||
aba3e65f DSH |
740 | =head1 SEE ALSO |
741 | ||
9b86974e | 742 | L<req(1)>, L<spkac(1)>, L<x509(1)>, L<CA.pl(1)>, |
1bc74519 | 743 | L<config(5)>, L<x509v3_config(5)> |
aba3e65f | 744 | |
e2f92610 RS |
745 | =head1 COPYRIGHT |
746 | ||
c4de074e | 747 | Copyright 2000-2017 The OpenSSL Project Authors. All Rights Reserved. |
e2f92610 RS |
748 | |
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>. | |
753 | ||
754 | =cut |