1 1.1 christos =pod 2 1.1 christos {- OpenSSL::safe::output_do_not_edit_headers(); -} 3 1.1 christos 4 1.1 christos =head1 NAME 5 1.1 christos 6 1.1 christos openssl-ca - sample minimal CA application 7 1.1 christos 8 1.1 christos =head1 SYNOPSIS 9 1.1 christos 10 1.1 christos B<openssl> B<ca> 11 1.1 christos [B<-help>] 12 1.1 christos [B<-verbose>] 13 1.1 christos [B<-config> I<filename>] 14 1.1 christos [B<-name> I<section>] 15 1.1 christos [B<-section> I<section>] 16 1.1 christos [B<-gencrl>] 17 1.1 christos [B<-revoke> I<file>] 18 1.1 christos [B<-valid> I<file>] 19 1.1 christos [B<-status> I<serial>] 20 1.1 christos [B<-updatedb>] 21 1.1 christos [B<-crl_reason> I<reason>] 22 1.1 christos [B<-crl_hold> I<instruction>] 23 1.1 christos [B<-crl_compromise> I<time>] 24 1.1 christos [B<-crl_CA_compromise> I<time>] 25 1.1 christos [B<-crl_lastupdate> I<date>] 26 1.1 christos [B<-crl_nextupdate> I<date>] 27 1.1 christos [B<-crldays> I<days>] 28 1.1 christos [B<-crlhours> I<hours>] 29 1.1 christos [B<-crlsec> I<seconds>] 30 1.1 christos [B<-crlexts> I<section>] 31 1.1 christos [B<-startdate> I<date>] 32 1.1 christos [B<-enddate> I<date>] 33 1.1 christos [B<-days> I<arg>] 34 1.1 christos [B<-md> I<arg>] 35 1.1 christos [B<-policy> I<arg>] 36 1.1 christos [B<-keyfile> I<filename>|I<uri>] 37 1.1 christos [B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>] 38 1.1 christos [B<-key> I<arg>] 39 1.1 christos [B<-passin> I<arg>] 40 1.1 christos [B<-cert> I<file>] 41 1.1 christos [B<-certform> B<DER>|B<PEM>|B<P12>] 42 1.1 christos [B<-selfsign>] 43 1.1 christos [B<-in> I<file>] 44 1.1 christos [B<-inform> B<DER>|<PEM>] 45 1.1 christos [B<-out> I<file>] 46 1.1 christos [B<-notext>] 47 1.1 christos [B<-dateopt>] 48 1.1 christos [B<-outdir> I<dir>] 49 1.1 christos [B<-infiles>] 50 1.1 christos [B<-spkac> I<file>] 51 1.1 christos [B<-ss_cert> I<file>] 52 1.1 christos [B<-preserveDN>] 53 1.1 christos [B<-noemailDN>] 54 1.1 christos [B<-batch>] 55 1.1 christos [B<-msie_hack>] 56 1.1 christos [B<-extensions> I<section>] 57 1.1 christos [B<-extfile> I<section>] 58 1.1 christos [B<-subj> I<arg>] 59 1.1 christos [B<-utf8>] 60 1.1 christos [B<-sigopt> I<nm>:I<v>] 61 1.1 christos [B<-vfyopt> I<nm>:I<v>] 62 1.1 christos [B<-create_serial>] 63 1.1 christos [B<-rand_serial>] 64 1.1 christos [B<-multivalue-rdn>] 65 1.1 christos {- $OpenSSL::safe::opt_r_synopsis -} 66 1.1 christos {- $OpenSSL::safe::opt_engine_synopsis -}{- $OpenSSL::safe::opt_provider_synopsis -} 67 1.1 christos [I<certreq>...] 68 1.1 christos 69 1.1 christos =head1 DESCRIPTION 70 1.1 christos 71 1.1 christos This command emulates a CA application. 72 1.1 christos See the B<WARNINGS> especially when considering to use it productively. 73 1.1 christos It can be used to sign certificate requests (CSRs) in a variety of forms 74 1.1 christos and generate certificate revocation lists (CRLs). 75 1.1 christos It also maintains a text database of issued certificates and their status. 76 1.1 christos When signing certificates, a single request can be specified 77 1.1 christos with the B<-in> option, or multiple requests can be processed by 78 1.1 christos specifying a set of B<certreq> files after all options. 79 1.1 christos 80 1.1 christos Note that there are also very lean ways of generating certificates: 81 1.1 christos the B<req> and B<x509> commands can be used for directly creating certificates. 82 1.1 christos See L<openssl-req(1)> and L<openssl-x509(1)> for details. 83 1.1 christos 84 1.1 christos The descriptions of the B<ca> command options are divided into each purpose. 85 1.1 christos 86 1.1 christos =head1 OPTIONS 87 1.1 christos 88 1.1 christos =over 4 89 1.1 christos 90 1.1 christos =item B<-help> 91 1.1 christos 92 1.1 christos Print out a usage message. 93 1.1 christos 94 1.1 christos =item B<-verbose> 95 1.1 christos 96 1.1 christos This prints extra details about the operations being performed. 97 1.1 christos 98 1.1 christos =item B<-config> I<filename> 99 1.1 christos 100 1.1 christos Specifies the configuration file to use. 101 1.1 christos Optional; for a description of the default value, 102 1.1 christos see L<openssl(1)/COMMAND SUMMARY>. 103 1.1 christos 104 1.1 christos =item B<-name> I<section>, B<-section> I<section> 105 1.1 christos 106 1.1 christos Specifies the configuration file section to use (overrides 107 1.1 christos B<default_ca> in the B<ca> section). 108 1.1 christos 109 1.1 christos =item B<-in> I<filename> 110 1.1 christos 111 1.1 christos An input filename containing a single certificate request (CSR) to be 112 1.1 christos signed by the CA. 113 1.1 christos 114 1.1 christos =item B<-inform> B<DER>|B<PEM> 115 1.1 christos 116 1.1 christos The format of the data in certificate request input files; 117 1.1 christos unspecified by default. 118 1.1 christos See L<openssl-format-options(1)> for details. 119 1.1 christos 120 1.1 christos =item B<-ss_cert> I<filename> 121 1.1 christos 122 1.1 christos A single self-signed certificate to be signed by the CA. 123 1.1 christos 124 1.1 christos =item B<-spkac> I<filename> 125 1.1 christos 126 1.1 christos A file containing a single Netscape signed public key and challenge 127 1.1 christos and additional field values to be signed by the CA. See the B<SPKAC FORMAT> 128 1.1 christos section for information on the required input and output format. 129 1.1 christos 130 1.1 christos =item B<-infiles> 131 1.1 christos 132 1.1 christos If present this should be the last option, all subsequent arguments 133 1.1 christos are taken as the names of files containing certificate requests. 134 1.1 christos 135 1.1 christos =item B<-out> I<filename> 136 1.1 christos 137 1.1 christos The output file to output certificates to. The default is standard 138 1.1 christos output. The certificate details will also be printed out to this 139 1.1 christos file in PEM format (except that B<-spkac> outputs DER format). 140 1.1 christos 141 1.1 christos =item B<-outdir> I<directory> 142 1.1 christos 143 1.1 christos The directory to output certificates to. The certificate will be 144 1.1 christos written to a filename consisting of the serial number in hex with 145 1.1 christos F<.pem> appended. 146 1.1 christos 147 1.1 christos =item B<-cert> I<filename> 148 1.1 christos 149 1.1 christos The CA certificate, which must match with B<-keyfile>. 150 1.1 christos 151 1.1 christos =item B<-certform> B<DER>|B<PEM>|B<P12> 152 1.1 christos 153 1.1 christos The format of the data in certificate input files; unspecified by default. 154 1.1 christos See L<openssl-format-options(1)> for details. 155 1.1 christos 156 1.1 christos =item B<-keyfile> I<filename>|I<uri> 157 1.1 christos 158 1.1 christos The CA private key to sign certificate requests with. 159 1.1 christos This must match with B<-cert>. 160 1.1 christos 161 1.1 christos =item B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE> 162 1.1 christos 163 1.1 christos The format of the private key input file; unspecified by default. 164 1.1 christos See L<openssl-format-options(1)> for details. 165 1.1 christos 166 1.1 christos =item B<-sigopt> I<nm>:I<v> 167 1.1 christos 168 1.1 christos Pass options to the signature algorithm during sign operations. 169 1.1 christos Names and values of these options are algorithm-specific. 170 1.1 christos 171 1.1 christos =item B<-vfyopt> I<nm>:I<v> 172 1.1 christos 173 1.1 christos Pass options to the signature algorithm during verify operations. 174 1.1 christos Names and values of these options are algorithm-specific. 175 1.1 christos 176 1.1 christos This often needs to be given while signing too, because the self-signature of 177 1.1 christos a certificate signing request (CSR) is verified against the included public key, 178 1.1 christos and that verification may need its own set of options. 179 1.1 christos 180 1.1 christos =item B<-key> I<password> 181 1.1 christos 182 1.1 christos =for openssl foreign manual ps(1) 183 1.1 christos 184 1.1 christos The password used to encrypt the private key. Since on some 185 1.1 christos systems the command line arguments are visible (e.g., when using 186 1.1 christos L<ps(1)> on Unix), 187 1.1 christos this option should be used with caution. 188 1.1 christos Better use B<-passin>. 189 1.1 christos 190 1.1 christos =item B<-passin> I<arg> 191 1.1 christos 192 1.1 christos The key password source for key files and certificate PKCS#12 files. 193 1.1 christos For more information about the format of B<arg> 194 1.1 christos see L<openssl-passphrase-options(1)>. 195 1.1 christos 196 1.1 christos =item B<-selfsign> 197 1.1 christos 198 1.1 christos Indicates the issued certificates are to be signed with the key 199 1.1 christos the certificate requests were signed with (given with B<-keyfile>). 200 1.1 christos Certificate requests signed with a different key are ignored. 201 1.1 christos If B<-spkac>, B<-ss_cert> or B<-gencrl> are given, B<-selfsign> is ignored. 202 1.1 christos 203 1.1 christos A consequence of using B<-selfsign> is that the self-signed 204 1.1 christos certificate appears among the entries in the certificate database 205 1.1 christos (see the configuration option B<database>), and uses the same 206 1.1 christos serial number counter as all other certificates sign with the 207 1.1 christos self-signed certificate. 208 1.1 christos 209 1.1 christos =item B<-notext> 210 1.1 christos 211 1.1 christos Don't output the text form of a certificate to the output file. 212 1.1 christos 213 1.1 christos =item B<-dateopt> 214 1.1 christos 215 1.1 christos Specify the date output format. Values are: rfc_822 and iso_8601. 216 1.1 christos Defaults to rfc_822. 217 1.1 christos 218 1.1 christos =item B<-startdate> I<date> 219 1.1 christos 220 1.1 christos This allows the start date to be explicitly set. The format of the 221 1.1 christos date is YYMMDDHHMMSSZ (the same as an ASN1 UTCTime structure), or 222 1.1 christos YYYYMMDDHHMMSSZ (the same as an ASN1 GeneralizedTime structure). In 223 1.1 christos both formats, seconds SS and timezone Z must be present. 224 1.1 christos 225 1.1 christos =item B<-enddate> I<date> 226 1.1 christos 227 1.1 christos This allows the expiry date to be explicitly set. The format of the 228 1.1 christos date is YYMMDDHHMMSSZ (the same as an ASN1 UTCTime structure), or 229 1.1 christos YYYYMMDDHHMMSSZ (the same as an ASN1 GeneralizedTime structure). In 230 1.1 christos both formats, seconds SS and timezone Z must be present. 231 1.1 christos 232 1.1 christos =item B<-days> I<arg> 233 1.1 christos 234 1.1 christos The number of days to certify the certificate for. 235 1.1 christos 236 1.1 christos =item B<-md> I<alg> 237 1.1 christos 238 1.1 christos The message digest to use. 239 1.1 christos Any digest supported by the L<openssl-dgst(1)> command can be used. For signing 240 1.1 christos algorithms that do not support a digest (i.e. Ed25519 and Ed448) any message 241 1.1 christos digest that is set is ignored. This option also applies to CRLs. 242 1.1 christos 243 1.1 christos =item B<-policy> I<arg> 244 1.1 christos 245 1.1 christos This option defines the CA "policy" to use. This is a section in 246 1.1 christos the configuration file which decides which fields should be mandatory 247 1.1 christos or match the CA certificate. Check out the B<POLICY FORMAT> section 248 1.1 christos for more information. 249 1.1 christos 250 1.1 christos =item B<-msie_hack> 251 1.1 christos 252 1.1 christos This is a deprecated option to make this command work with very old versions 253 1.1 christos of the IE certificate enrollment control "certenr3". It used UniversalStrings 254 1.1 christos for almost everything. Since the old control has various security bugs 255 1.1 christos its use is strongly discouraged. 256 1.1 christos 257 1.1 christos =item B<-preserveDN> 258 1.1 christos 259 1.1 christos Normally the DN order of a certificate is the same as the order of the 260 1.1 christos fields in the relevant policy section. When this option is set the order 261 1.1 christos is the same as the request. This is largely for compatibility with the 262 1.1 christos older IE enrollment control which would only accept certificates if their 263 1.1 christos DNs match the order of the request. This is not needed for Xenroll. 264 1.1 christos 265 1.1 christos =item B<-noemailDN> 266 1.1 christos 267 1.1 christos The DN of a certificate can contain the EMAIL field if present in the 268 1.1 christos request DN, however, it is good policy just having the e-mail set into 269 1.1 christos the altName extension of the certificate. When this option is set the 270 1.1 christos EMAIL field is removed from the certificate' subject and set only in 271 1.1 christos the, eventually present, extensions. The B<email_in_dn> keyword can be 272 1.1 christos used in the configuration file to enable this behaviour. 273 1.1 christos 274 1.1 christos =item B<-batch> 275 1.1 christos 276 1.1 christos This sets the batch mode. In this mode no questions will be asked 277 1.1 christos and all certificates will be certified automatically. 278 1.1 christos 279 1.1 christos =item B<-extensions> I<section> 280 1.1 christos 281 1.1 christos The section of the configuration file containing certificate extensions 282 1.1 christos to be added when a certificate is issued (defaults to B<x509_extensions> 283 1.1 christos unless the B<-extfile> option is used). 284 1.1 christos If no X.509 extensions are specified then a V1 certificate is created, 285 1.1 christos else a V3 certificate is created. 286 1.1 christos See the L<x509v3_config(5)> manual page for details of the 287 1.1 christos extension section format. 288 1.1 christos 289 1.1 christos =item B<-extfile> I<file> 290 1.1 christos 291 1.1 christos An additional configuration file to read certificate extensions from 292 1.1 christos (using the default section unless the B<-extensions> option is also 293 1.1 christos used). 294 1.1 christos 295 1.1 christos =item B<-subj> I<arg> 296 1.1 christos 297 1.1 christos Supersedes subject name given in the request. 298 1.1 christos 299 1.1 christos The arg must be formatted as C</type0=value0/type1=value1/type2=...>. 300 1.1 christos Special characters may be escaped by C<\> (backslash), whitespace is retained. 301 1.1 christos Empty values are permitted, but the corresponding type will not be included 302 1.1 christos in the resulting certificate. 303 1.1 christos Giving a single C</> will lead to an empty sequence of RDNs (a NULL-DN). 304 1.1 christos Multi-valued RDNs can be formed by placing a C<+> character instead of a C</> 305 1.1 christos between the AttributeValueAssertions (AVAs) that specify the members of the set. 306 1.1 christos Example: 307 1.1 christos 308 1.1 christos C</DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe> 309 1.1 christos 310 1.1 christos =item B<-utf8> 311 1.1 christos 312 1.1 christos This option causes field values to be interpreted as UTF8 strings, by 313 1.1 christos default they are interpreted as ASCII. This means that the field 314 1.1 christos values, whether prompted from a terminal or obtained from a 315 1.1 christos configuration file, must be valid UTF8 strings. 316 1.1 christos 317 1.1 christos =item B<-create_serial> 318 1.1 christos 319 1.1 christos If reading serial from the text file as specified in the configuration 320 1.1 christos fails, specifying this option creates a new random serial to be used as next 321 1.1 christos serial number. 322 1.1 christos To get random serial numbers, use the B<-rand_serial> flag instead; this 323 1.1 christos should only be used for simple error-recovery. 324 1.1 christos 325 1.1 christos =item B<-rand_serial> 326 1.1 christos 327 1.1 christos Generate a large random number to use as the serial number. 328 1.1 christos This overrides any option or configuration to use a serial number file. 329 1.1 christos 330 1.1 christos =item B<-multivalue-rdn> 331 1.1 christos 332 1.1 christos This option has been deprecated and has no effect. 333 1.1 christos 334 1.1 christos {- $OpenSSL::safe::opt_r_item -} 335 1.1 christos 336 1.1 christos {- $OpenSSL::safe::opt_engine_item -} 337 1.1 christos 338 1.1 christos {- $OpenSSL::safe::opt_provider_item -} 339 1.1 christos 340 1.1 christos =back 341 1.1 christos 342 1.1 christos =head1 CRL OPTIONS 343 1.1 christos 344 1.1 christos =over 4 345 1.1 christos 346 1.1 christos =item B<-gencrl> 347 1.1 christos 348 1.1 christos This option generates a CRL based on information in the index file. 349 1.1 christos 350 1.1 christos =item B<-crl_lastupdate> I<time> 351 1.1 christos 352 1.1 christos Allows the value of the CRL's lastUpdate field to be explicitly set; if 353 1.1 christos this option is not present, the current time is used. Accepts times in 354 1.1 christos YYMMDDHHMMSSZ format (the same as an ASN1 UTCTime structure) or 355 1.1 christos YYYYMMDDHHMMSSZ format (the same as an ASN1 GeneralizedTime structure). 356 1.1 christos 357 1.1 christos =item B<-crl_nextupdate> I<time> 358 1.1 christos 359 1.1 christos Allows the value of the CRL's nextUpdate field to be explicitly set; if 360 1.1 christos this option is present, any values given for B<-crldays>, B<-crlhours> 361 1.1 christos and B<-crlsec> are ignored. Accepts times in the same formats as 362 1.1 christos B<-crl_lastupdate>. 363 1.1 christos 364 1.1 christos =item B<-crldays> I<num> 365 1.1 christos 366 1.1 christos The number of days before the next CRL is due. That is the days from 367 1.1 christos now to place in the CRL nextUpdate field. 368 1.1 christos 369 1.1 christos =item B<-crlhours> I<num> 370 1.1 christos 371 1.1 christos The number of hours before the next CRL is due. 372 1.1 christos 373 1.1 christos =item B<-crlsec> I<num> 374 1.1 christos 375 1.1 christos The number of seconds before the next CRL is due. 376 1.1 christos 377 1.1 christos =item B<-revoke> I<filename> 378 1.1 christos 379 1.1 christos A filename containing a certificate to revoke. 380 1.1 christos 381 1.1 christos =item B<-valid> I<filename> 382 1.1 christos 383 1.1 christos A filename containing a certificate to add a Valid certificate entry. 384 1.1 christos 385 1.1 christos =item B<-status> I<serial> 386 1.1 christos 387 1.1 christos Displays the revocation status of the certificate with the specified 388 1.1 christos serial number and exits. 389 1.1 christos 390 1.1 christos =item B<-updatedb> 391 1.1 christos 392 1.1 christos Updates the database index to purge expired certificates. 393 1.1 christos 394 1.1 christos =item B<-crl_reason> I<reason> 395 1.1 christos 396 1.1 christos Revocation reason, where I<reason> is one of: B<unspecified>, B<keyCompromise>, 397 1.1 christos B<CACompromise>, B<affiliationChanged>, B<superseded>, B<cessationOfOperation>, 398 1.1 christos B<certificateHold> or B<removeFromCRL>. The matching of I<reason> is case 399 1.1 christos insensitive. Setting any revocation reason will make the CRL v2. 400 1.1 christos 401 1.1 christos In practice B<removeFromCRL> is not particularly useful because it is only used 402 1.1 christos in delta CRLs which are not currently implemented. 403 1.1 christos 404 1.1 christos =item B<-crl_hold> I<instruction> 405 1.1 christos 406 1.1 christos This sets the CRL revocation reason code to B<certificateHold> and the hold 407 1.1 christos instruction to I<instruction> which must be an OID. Although any OID can be 408 1.1 christos used only B<holdInstructionNone> (the use of which is discouraged by RFC2459) 409 1.1 christos B<holdInstructionCallIssuer> or B<holdInstructionReject> will normally be used. 410 1.1 christos 411 1.1 christos =item B<-crl_compromise> I<time> 412 1.1 christos 413 1.1 christos This sets the revocation reason to B<keyCompromise> and the compromise time to 414 1.1 christos I<time>. I<time> should be in GeneralizedTime format that is I<YYYYMMDDHHMMSSZ>. 415 1.1 christos 416 1.1 christos =item B<-crl_CA_compromise> I<time> 417 1.1 christos 418 1.1 christos This is the same as B<crl_compromise> except the revocation reason is set to 419 1.1 christos B<CACompromise>. 420 1.1 christos 421 1.1 christos =item B<-crlexts> I<section> 422 1.1 christos 423 1.1 christos The section of the configuration file containing CRL extensions to 424 1.1 christos include. If no CRL extension section is present then a V1 CRL is 425 1.1 christos created, if the CRL extension section is present (even if it is 426 1.1 christos empty) then a V2 CRL is created. The CRL extensions specified are 427 1.1 christos CRL extensions and B<not> CRL entry extensions. It should be noted 428 1.1 christos that some software (for example Netscape) can't handle V2 CRLs. See 429 1.1 christos L<x509v3_config(5)> manual page for details of the 430 1.1 christos extension section format. 431 1.1 christos 432 1.1 christos =back 433 1.1 christos 434 1.1 christos =head1 CONFIGURATION FILE OPTIONS 435 1.1 christos 436 1.1 christos The section of the configuration file containing options for this command 437 1.1 christos is found as follows: If the B<-name> command line option is used, 438 1.1 christos then it names the section to be used. Otherwise the section to 439 1.1 christos be used must be named in the B<default_ca> option of the B<ca> section 440 1.1 christos of the configuration file (or in the default section of the 441 1.1 christos configuration file). Besides B<default_ca>, the following options are 442 1.1 christos read directly from the B<ca> section: 443 1.1 christos RANDFILE 444 1.1 christos preserve 445 1.1 christos msie_hack 446 1.1 christos With the exception of B<RANDFILE>, this is probably a bug and may 447 1.1 christos change in future releases. 448 1.1 christos 449 1.1 christos Many of the configuration file options are identical to command line 450 1.1 christos options. Where the option is present in the configuration file 451 1.1 christos and the command line the command line value is used. Where an 452 1.1 christos option is described as mandatory then it must be present in 453 1.1 christos the configuration file or the command line equivalent (if 454 1.1 christos any) used. 455 1.1 christos 456 1.1 christos =over 4 457 1.1 christos 458 1.1 christos =item B<oid_file> 459 1.1 christos 460 1.1 christos This specifies a file containing additional B<OBJECT IDENTIFIERS>. 461 1.1 christos Each line of the file should consist of the numerical form of the 462 1.1 christos object identifier followed by whitespace then the short name followed 463 1.1 christos by whitespace and finally the long name. 464 1.1 christos 465 1.1 christos =item B<oid_section> 466 1.1 christos 467 1.1 christos This specifies a section in the configuration file containing extra 468 1.1 christos object identifiers. Each line should consist of the short name of the 469 1.1 christos object identifier followed by B<=> and the numerical form. The short 470 1.1 christos and long names are the same when this option is used. 471 1.1 christos 472 1.1 christos =item B<new_certs_dir> 473 1.1 christos 474 1.1 christos The same as the B<-outdir> command line option. It specifies 475 1.1 christos the directory where new certificates will be placed. Mandatory. 476 1.1 christos 477 1.1 christos =item B<certificate> 478 1.1 christos 479 1.1 christos The same as B<-cert>. It gives the file containing the CA 480 1.1 christos certificate. Mandatory. 481 1.1 christos 482 1.1 christos =item B<private_key> 483 1.1 christos 484 1.1 christos Same as the B<-keyfile> option. The file containing the 485 1.1 christos CA private key. Mandatory. 486 1.1 christos 487 1.1 christos =item B<RANDFILE> 488 1.1 christos 489 1.1 christos At startup the specified file is loaded into the random number generator, 490 1.1 christos and at exit 256 bytes will be written to it. (Note: Using a RANDFILE is 491 1.1 christos not necessary anymore, see the L</HISTORY> section. 492 1.1 christos 493 1.1 christos =item B<default_days> 494 1.1 christos 495 1.1 christos The same as the B<-days> option. The number of days to certify 496 1.1 christos a certificate for. 497 1.1 christos 498 1.1 christos =item B<default_startdate> 499 1.1 christos 500 1.1 christos The same as the B<-startdate> option. The start date to certify 501 1.1 christos a certificate for. If not set the current time is used. 502 1.1 christos 503 1.1 christos =item B<default_enddate> 504 1.1 christos 505 1.1 christos The same as the B<-enddate> option. Either this option or 506 1.1 christos B<default_days> (or the command line equivalents) must be 507 1.1 christos present. 508 1.1 christos 509 1.1 christos =item B<default_crl_hours default_crl_days> 510 1.1 christos 511 1.1 christos The same as the B<-crlhours> and the B<-crldays> options. These 512 1.1 christos will only be used if neither command line option is present. At 513 1.1 christos least one of these must be present to generate a CRL. 514 1.1 christos 515 1.1 christos =item B<default_md> 516 1.1 christos 517 1.1 christos The same as the B<-md> option. Mandatory except where the signing algorithm does 518 1.1 christos not require a digest (i.e. Ed25519 and Ed448). 519 1.1 christos 520 1.1 christos =item B<database> 521 1.1 christos 522 1.1 christos The text database file to use. Mandatory. This file must be present 523 1.1 christos though initially it will be empty. 524 1.1 christos 525 1.1 christos =item B<unique_subject> 526 1.1 christos 527 1.1 christos If the value B<yes> is given, the valid certificate entries in the 528 1.1 christos database must have unique subjects. if the value B<no> is given, 529 1.1 christos several valid certificate entries may have the exact same subject. 530 1.1 christos The default value is B<yes>, to be compatible with older (pre 0.9.8) 531 1.1 christos versions of OpenSSL. However, to make CA certificate roll-over easier, 532 1.1 christos it's recommended to use the value B<no>, especially if combined with 533 1.1 christos the B<-selfsign> command line option. 534 1.1 christos 535 1.1 christos Note that it is valid in some circumstances for certificates to be created 536 1.1 christos without any subject. In the case where there are multiple certificates without 537 1.1 christos subjects this does not count as a duplicate. 538 1.1 christos 539 1.1 christos =item B<serial> 540 1.1 christos 541 1.1 christos A text file containing the next serial number to use in hex. Mandatory. 542 1.1 christos This file must be present and contain a valid serial number. 543 1.1 christos 544 1.1 christos =item B<crlnumber> 545 1.1 christos 546 1.1 christos A text file containing the next CRL number to use in hex. The crl number 547 1.1 christos will be inserted in the CRLs only if this file exists. If this file is 548 1.1 christos present, it must contain a valid CRL number. 549 1.1 christos 550 1.1 christos =item B<x509_extensions> 551 1.1 christos 552 1.1 christos A fallback to the B<-extensions> option. 553 1.1 christos 554 1.1 christos =item B<crl_extensions> 555 1.1 christos 556 1.1 christos A fallback to the B<-crlexts> option. 557 1.1 christos 558 1.1 christos =item B<preserve> 559 1.1 christos 560 1.1 christos The same as B<-preserveDN> 561 1.1 christos 562 1.1 christos =item B<email_in_dn> 563 1.1 christos 564 1.1 christos The same as B<-noemailDN>. If you want the EMAIL field to be removed 565 1.1 christos from the DN of the certificate simply set this to 'no'. If not present 566 1.1 christos the default is to allow for the EMAIL filed in the certificate's DN. 567 1.1 christos 568 1.1 christos =item B<msie_hack> 569 1.1 christos 570 1.1 christos The same as B<-msie_hack> 571 1.1 christos 572 1.1 christos =item B<policy> 573 1.1 christos 574 1.1 christos The same as B<-policy>. Mandatory. See the B<POLICY FORMAT> section 575 1.1 christos for more information. 576 1.1 christos 577 1.1 christos =item B<name_opt>, B<cert_opt> 578 1.1 christos 579 1.1 christos These options allow the format used to display the certificate details 580 1.1 christos when asking the user to confirm signing. All the options supported by 581 1.1 christos the B<x509> utilities B<-nameopt> and B<-certopt> switches can be used 582 1.1 christos here, except the B<no_signame> and B<no_sigdump> are permanently set 583 1.1 christos and cannot be disabled (this is because the certificate signature cannot 584 1.1 christos be displayed because the certificate has not been signed at this point). 585 1.1 christos 586 1.1 christos For convenience the values B<ca_default> are accepted by both to produce 587 1.1 christos a reasonable output. 588 1.1 christos 589 1.1 christos If neither option is present the format used in earlier versions of 590 1.1 christos OpenSSL is used. Use of the old format is B<strongly> discouraged because 591 1.1 christos it only displays fields mentioned in the B<policy> section, mishandles 592 1.1 christos multicharacter string types and does not display extensions. 593 1.1 christos 594 1.1 christos =item B<copy_extensions> 595 1.1 christos 596 1.1 christos Determines how extensions in certificate requests should be handled. 597 1.1 christos If set to B<none> or this option is not present then extensions are 598 1.1 christos ignored and not copied to the certificate. If set to B<copy> then any 599 1.1 christos extensions present in the request that are not already present are copied 600 1.1 christos to the certificate. If set to B<copyall> then all extensions in the 601 1.1 christos request are copied to the certificate: if the extension is already present 602 1.1 christos in the certificate it is deleted first. See the B<WARNINGS> section before 603 1.1 christos using this option. 604 1.1 christos 605 1.1 christos The main use of this option is to allow a certificate request to supply 606 1.1 christos values for certain extensions such as subjectAltName. 607 1.1 christos 608 1.1 christos =back 609 1.1 christos 610 1.1 christos =head1 POLICY FORMAT 611 1.1 christos 612 1.1 christos The policy section consists of a set of variables corresponding to 613 1.1 christos certificate DN fields. If the value is "match" then the field value 614 1.1 christos must match the same field in the CA certificate. If the value is 615 1.1 christos "supplied" then it must be present. If the value is "optional" then 616 1.1 christos it may be present. Any fields not mentioned in the policy section 617 1.1 christos are silently deleted, unless the B<-preserveDN> option is set but 618 1.1 christos this can be regarded more of a quirk than intended behaviour. 619 1.1 christos 620 1.1 christos =head1 SPKAC FORMAT 621 1.1 christos 622 1.1 christos The input to the B<-spkac> command line option is a Netscape 623 1.1 christos signed public key and challenge. This will usually come from 624 1.1 christos the B<KEYGEN> tag in an HTML form to create a new private key. 625 1.1 christos It is however possible to create SPKACs using L<openssl-spkac(1)>. 626 1.1 christos 627 1.1 christos The file should contain the variable SPKAC set to the value of 628 1.1 christos the SPKAC and also the required DN components as name value pairs. 629 1.1 christos If you need to include the same component twice then it can be 630 1.1 christos preceded by a number and a '.'. 631 1.1 christos 632 1.1 christos When processing SPKAC format, the output is DER if the B<-out> 633 1.1 christos flag is used, but PEM format if sending to stdout or the B<-outdir> 634 1.1 christos flag is used. 635 1.1 christos 636 1.1 christos =head1 EXAMPLES 637 1.1 christos 638 1.1 christos Note: these examples assume that the directory structure this command 639 1.1 christos assumes is already set up and the relevant files already exist. This 640 1.1 christos usually involves creating a CA certificate and private key with 641 1.1 christos L<openssl-req(1)>, a serial number file and an empty index file and 642 1.1 christos placing them in the relevant directories. 643 1.1 christos 644 1.1 christos To use the sample configuration file below the directories F<demoCA>, 645 1.1 christos F<demoCA/private> and F<demoCA/newcerts> would be created. The CA 646 1.1 christos certificate would be copied to F<demoCA/cacert.pem> and its private 647 1.1 christos key to F<demoCA/private/cakey.pem>. A file F<demoCA/serial> would be 648 1.1 christos created containing for example "01" and the empty index file 649 1.1 christos F<demoCA/index.txt>. 650 1.1 christos 651 1.1 christos 652 1.1 christos Sign a certificate request: 653 1.1 christos 654 1.1 christos openssl ca -in req.pem -out newcert.pem 655 1.1 christos 656 1.1 christos Sign an SM2 certificate request: 657 1.1 christos 658 1.1 christos openssl ca -in sm2.csr -out sm2.crt -md sm3 \ 659 1.1 christos -sigopt "distid:1234567812345678" \ 660 1.1 christos -vfyopt "distid:1234567812345678" 661 1.1 christos 662 1.1 christos Sign a certificate request, using CA extensions: 663 1.1 christos 664 1.1 christos openssl ca -in req.pem -extensions v3_ca -out newcert.pem 665 1.1 christos 666 1.1 christos Generate a CRL 667 1.1 christos 668 1.1 christos openssl ca -gencrl -out crl.pem 669 1.1 christos 670 1.1 christos Sign several requests: 671 1.1 christos 672 1.1 christos openssl ca -infiles req1.pem req2.pem req3.pem 673 1.1 christos 674 1.1 christos Certify a Netscape SPKAC: 675 1.1 christos 676 1.1 christos openssl ca -spkac spkac.txt 677 1.1 christos 678 1.1 christos A sample SPKAC file (the SPKAC line has been truncated for clarity): 679 1.1 christos 680 1.1 christos SPKAC=MIG0MGAwXDANBgkqhkiG9w0BAQEFAANLADBIAkEAn7PDhCeV/xIxUg8V70YRxK2A5 681 1.1 christos CN=Steve Test 682 1.1 christos emailAddress=steve (a] openssl.org 683 1.1 christos 0.OU=OpenSSL Group 684 1.1 christos 1.OU=Another Group 685 1.1 christos 686 1.1 christos A sample configuration file with the relevant sections for this command: 687 1.1 christos 688 1.1 christos [ ca ] 689 1.1 christos default_ca = CA_default # The default ca section 690 1.1 christos 691 1.1 christos [ CA_default ] 692 1.1 christos 693 1.1 christos dir = ./demoCA # top dir 694 1.1 christos database = $dir/index.txt # index file. 695 1.1 christos new_certs_dir = $dir/newcerts # new certs dir 696 1.1 christos 697 1.1 christos certificate = $dir/cacert.pem # The CA cert 698 1.1 christos serial = $dir/serial # serial no file 699 1.1 christos #rand_serial = yes # for random serial#'s 700 1.1 christos private_key = $dir/private/cakey.pem# CA private key 701 1.1 christos 702 1.1 christos default_days = 365 # how long to certify for 703 1.1 christos default_crl_days= 30 # how long before next CRL 704 1.3 christos default_md = sha256 # md to use 705 1.1 christos 706 1.1 christos policy = policy_any # default policy 707 1.1 christos email_in_dn = no # Don't add the email into cert DN 708 1.1 christos 709 1.1 christos name_opt = ca_default # Subject name display option 710 1.1 christos cert_opt = ca_default # Certificate display option 711 1.1 christos copy_extensions = none # Don't copy extensions from request 712 1.1 christos 713 1.1 christos [ policy_any ] 714 1.1 christos countryName = supplied 715 1.1 christos stateOrProvinceName = optional 716 1.1 christos organizationName = optional 717 1.1 christos organizationalUnitName = optional 718 1.1 christos commonName = supplied 719 1.1 christos emailAddress = optional 720 1.1 christos 721 1.1 christos =head1 FILES 722 1.1 christos 723 1.1 christos Note: the location of all files can change either by compile time options, 724 1.1 christos configuration file entries, environment variables or command line options. 725 1.1 christos The values below reflect the default values. 726 1.1 christos 727 1.1 christos /usr/local/ssl/lib/openssl.cnf - master configuration file 728 1.1 christos ./demoCA - main CA directory 729 1.1 christos ./demoCA/cacert.pem - CA certificate 730 1.1 christos ./demoCA/private/cakey.pem - CA private key 731 1.1 christos ./demoCA/serial - CA serial number file 732 1.1 christos ./demoCA/serial.old - CA serial number backup file 733 1.1 christos ./demoCA/index.txt - CA text database file 734 1.1 christos ./demoCA/index.txt.old - CA text database backup file 735 1.1 christos ./demoCA/certs - certificate output file 736 1.1 christos 737 1.1 christos =head1 RESTRICTIONS 738 1.1 christos 739 1.1 christos The text database index file is a critical part of the process and 740 1.1 christos if corrupted it can be difficult to fix. It is theoretically possible 741 1.1 christos to rebuild the index file from all the issued certificates and a current 742 1.1 christos CRL: however there is no option to do this. 743 1.1 christos 744 1.1 christos V2 CRL features like delta CRLs are not currently supported. 745 1.1 christos 746 1.1 christos Although several requests can be input and handled at once it is only 747 1.1 christos possible to include one SPKAC or self-signed certificate. 748 1.1 christos 749 1.1 christos =head1 BUGS 750 1.1 christos 751 1.1 christos This command is quirky and at times downright unfriendly. 752 1.1 christos 753 1.1 christos The use of an in-memory text database can cause problems when large 754 1.1 christos numbers of certificates are present because, as the name implies 755 1.1 christos the database has to be kept in memory. 756 1.1 christos 757 1.1 christos This command really needs rewriting or the required functionality 758 1.1 christos exposed at either a command or interface level so that a more user-friendly 759 1.1 christos replacement could handle things properly. The script 760 1.1 christos B<CA.pl> helps a little but not very much. 761 1.1 christos 762 1.1 christos Any fields in a request that are not present in a policy are silently 763 1.1 christos deleted. This does not happen if the B<-preserveDN> option is used. To 764 1.1 christos enforce the absence of the EMAIL field within the DN, as suggested by 765 1.1 christos RFCs, regardless the contents of the request' subject the B<-noemailDN> 766 1.1 christos option can be used. The behaviour should be more friendly and 767 1.1 christos configurable. 768 1.1 christos 769 1.1 christos Canceling some commands by refusing to certify a certificate can 770 1.1 christos create an empty file. 771 1.1 christos 772 1.1 christos =head1 WARNINGS 773 1.1 christos 774 1.1 christos This command was originally meant as an example of how to do things in a CA. 775 1.1 christos Its code does not have production quality. 776 1.1 christos It was not supposed to be used as a full blown CA itself, 777 1.1 christos nevertheless some people are using it for this purpose at least internally. 778 1.1 christos When doing so, specific care should be taken to 779 1.1 christos properly secure the private key(s) used for signing certificates. 780 1.1 christos It is advisable to keep them in a secure HW storage such as a smart card or HSM 781 1.1 christos and access them via a suitable engine or crypto provider. 782 1.1 christos 783 1.1 christos This command command is effectively a single user command: no locking 784 1.1 christos is done on the various files and attempts to run more than one B<openssl ca> 785 1.1 christos command on the same database can have unpredictable results. 786 1.1 christos 787 1.1 christos The B<copy_extensions> option should be used with caution. If care is 788 1.1 christos not taken then it can be a security risk. For example if a certificate 789 1.1 christos request contains a basicConstraints extension with CA:TRUE and the 790 1.1 christos B<copy_extensions> value is set to B<copyall> and the user does not spot 791 1.1 christos this when the certificate is displayed then this will hand the requester 792 1.1 christos a valid CA certificate. 793 1.1 christos This situation can be avoided by setting B<copy_extensions> to B<copy> 794 1.1 christos and including basicConstraints with CA:FALSE in the configuration file. 795 1.1 christos Then if the request contains a basicConstraints extension it will be 796 1.1 christos ignored. 797 1.1 christos 798 1.1 christos It is advisable to also include values for other extensions such 799 1.1 christos as B<keyUsage> to prevent a request supplying its own values. 800 1.1 christos 801 1.1 christos Additional restrictions can be placed on the CA certificate itself. 802 1.1 christos For example if the CA certificate has: 803 1.1 christos 804 1.1 christos basicConstraints = CA:TRUE, pathlen:0 805 1.1 christos 806 1.1 christos then even if a certificate is issued with CA:TRUE it will not be valid. 807 1.1 christos 808 1.1 christos =head1 HISTORY 809 1.1 christos 810 1.1 christos Since OpenSSL 1.1.1, the program follows RFC5280. Specifically, 811 1.1 christos certificate validity period (specified by any of B<-startdate>, 812 1.1 christos B<-enddate> and B<-days>) and CRL last/next update time (specified by 813 1.1 christos any of B<-crl_lastupdate>, B<-crl_nextupdate>, B<-crldays>, B<-crlhours> 814 1.1 christos and B<-crlsec>) will be encoded as UTCTime if the dates are 815 1.1 christos earlier than year 2049 (included), and as GeneralizedTime if the dates 816 1.1 christos are in year 2050 or later. 817 1.1 christos 818 1.1 christos OpenSSL 1.1.1 introduced a new random generator (CSPRNG) with an improved 819 1.1 christos seeding mechanism. The new seeding mechanism makes it unnecessary to 820 1.1 christos define a RANDFILE for saving and restoring randomness. This option is 821 1.1 christos retained mainly for compatibility reasons. 822 1.1 christos 823 1.1 christos The B<-section> option was added in OpenSSL 3.0.0. 824 1.1 christos 825 1.1 christos The B<-multivalue-rdn> option has become obsolete in OpenSSL 3.0.0 and 826 1.1 christos has no effect. 827 1.1 christos 828 1.1 christos The B<-engine> option was deprecated in OpenSSL 3.0. 829 1.1 christos 830 1.1 christos =head1 SEE ALSO 831 1.1 christos 832 1.1 christos L<openssl(1)>, 833 1.1 christos L<openssl-req(1)>, 834 1.1 christos L<openssl-spkac(1)>, 835 1.1 christos L<openssl-x509(1)>, 836 1.1 christos L<CA.pl(1)>, 837 1.1 christos L<config(5)>, 838 1.1 christos L<x509v3_config(5)> 839 1.1 christos 840 1.1 christos =head1 COPYRIGHT 841 1.1 christos 842 1.1 christos Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved. 843 1.1 christos 844 1.1 christos Licensed under the Apache License 2.0 (the "License"). You may not use 845 1.1 christos this file except in compliance with the License. You can obtain a copy 846 1.1 christos in the file LICENSE in the source distribution or at 847 1.1 christos L<https://www.openssl.org/source/license.html>. 848 1.1 christos 849 1.1 christos =cut 850