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