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-x509 - Certificate display and signing command 7 1.1 christos 8 1.1 christos =head1 SYNOPSIS 9 1.1 christos 10 1.1 christos B<openssl> B<x509> 11 1.1 christos [B<-help>] 12 1.1 christos [B<-in> I<filename>|I<uri>] 13 1.1 christos [B<-passin> I<arg>] 14 1.1 christos [B<-new>] 15 1.1 christos [B<-x509toreq>] 16 1.1 christos [B<-req>] 17 1.1 christos [B<-copy_extensions> I<arg>] 18 1.1 christos [B<-inform> B<DER>|B<PEM>] 19 1.1 christos [B<-vfyopt> I<nm>:I<v>] 20 1.1 christos [B<-key> I<filename>|I<uri>] 21 1.1 christos [B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>] 22 1.1 christos [B<-signkey> I<filename>|I<uri>] 23 1.1 christos [B<-out> I<filename>] 24 1.1 christos [B<-outform> B<DER>|B<PEM>] 25 1.1 christos [B<-nocert>] 26 1.1 christos [B<-noout>] 27 1.1 christos [B<-dateopt>] 28 1.1 christos [B<-text>] 29 1.1 christos [B<-certopt> I<option>] 30 1.1 christos [B<-fingerprint>] 31 1.1 christos [B<-alias>] 32 1.1 christos [B<-serial>] 33 1.1 christos [B<-startdate>] 34 1.1 christos [B<-enddate>] 35 1.1 christos [B<-dates>] 36 1.1 christos [B<-subject>] 37 1.1 christos [B<-issuer>] 38 1.1 christos {- $OpenSSL::safe::opt_name_synopsis -} 39 1.1 christos [B<-email>] 40 1.1 christos [B<-hash>] 41 1.1 christos [B<-subject_hash>] 42 1.1 christos [B<-subject_hash_old>] 43 1.1 christos [B<-issuer_hash>] 44 1.1 christos [B<-issuer_hash_old>] 45 1.1 christos [B<-ext> I<extensions>] 46 1.1 christos [B<-ocspid>] 47 1.1 christos [B<-ocsp_uri>] 48 1.1 christos [B<-purpose>] 49 1.1 christos [B<-pubkey>] 50 1.1 christos [B<-modulus>] 51 1.1 christos [B<-checkend> I<num>] 52 1.1 christos [B<-checkhost> I<host>] 53 1.1 christos [B<-checkemail> I<host>] 54 1.1 christos [B<-checkip> I<ipaddr>] 55 1.1 christos [B<-set_serial> I<n>] 56 1.1 christos [B<-next_serial>] 57 1.1 christos [B<-not_before> I<date>] 58 1.1 christos [B<-not_after> I<date>] 59 1.1 christos [B<-days> I<arg>] 60 1.1 christos [B<-preserve_dates>] 61 1.1 christos [B<-set_issuer> I<arg>] 62 1.1 christos [B<-set_subject> I<arg>] 63 1.1 christos [B<-subj> I<arg>] 64 1.1 christos [B<-force_pubkey> I<filename>] 65 1.1 christos [B<-clrext>] 66 1.1 christos [B<-extfile> I<filename>] 67 1.1 christos [B<-extensions> I<section>] 68 1.1 christos [B<-sigopt> I<nm>:I<v>] 69 1.1 christos [B<-badsig>] 70 1.1 christos [B<-I<digest>>] 71 1.1 christos [B<-CA> I<filename>|I<uri>] 72 1.1 christos [B<-CAform> B<DER>|B<PEM>|B<P12>] 73 1.1 christos [B<-CAkey> I<filename>|I<uri>] 74 1.1 christos [B<-CAkeyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>] 75 1.1 christos [B<-CAserial> I<filename>] 76 1.1 christos [B<-CAcreateserial>] 77 1.1 christos [B<-trustout>] 78 1.1 christos [B<-setalias> I<arg>] 79 1.1 christos [B<-clrtrust>] 80 1.1 christos [B<-addtrust> I<arg>] 81 1.1 christos [B<-clrreject>] 82 1.1 christos [B<-addreject> I<arg>] 83 1.1 christos {- $OpenSSL::safe::opt_r_synopsis -} 84 1.1 christos {- $OpenSSL::safe::opt_engine_synopsis -}{- $OpenSSL::safe::opt_provider_synopsis -} 85 1.1 christos 86 1.1 christos =head1 DESCRIPTION 87 1.1 christos 88 1.1 christos This command is a multi-purposes certificate handling command. 89 1.1 christos It can be used to print certificate information, 90 1.1 christos convert certificates to various forms, edit certificate trust settings, 91 1.1 christos generate certificates from scratch or from certification requests 92 1.1 christos and then self-signing them or signing them like a "micro CA". 93 1.1 christos 94 1.1 christos Generated certificates bear X.509 version 3. 95 1.1 christos Unless specified otherwise, 96 1.1 christos key identifier extensions are included as described in L<x509v3_config(5)>. 97 1.1 christos 98 1.1 christos Since there are a large number of options they will split up into 99 1.1 christos various sections. 100 1.1 christos 101 1.1 christos =head1 OPTIONS 102 1.1 christos 103 1.1 christos =head2 Input, Output, and General Purpose Options 104 1.1 christos 105 1.1 christos =over 4 106 1.1 christos 107 1.1 christos =item B<-help> 108 1.1 christos 109 1.1 christos Print out a usage message. 110 1.1 christos 111 1.1 christos =item B<-in> I<filename>|I<uri> 112 1.1 christos 113 1.1 christos This specifies the input to read a certificate from 114 1.1 christos or the input file for reading a certificate request if the B<-req> flag is used. 115 1.1 christos In both cases this defaults to standard input. 116 1.1 christos 117 1.1 christos This option cannot be combined with the B<-new> flag. 118 1.1 christos 119 1.1 christos =item B<-passin> I<arg> 120 1.1 christos 121 1.1 christos The key and certificate file password source. 122 1.1 christos For more information about the format of I<arg> 123 1.1 christos see L<openssl-passphrase-options(1)>. 124 1.1 christos 125 1.1 christos =item B<-new> 126 1.1 christos 127 1.1 christos Generate a certificate from scratch, not using an input certificate 128 1.1 christos or certificate request. 129 1.1 christos So this excludes the B<-in> and B<-req> options. 130 1.1 christos Instead, the B<-set_subject> option needs to be given. 131 1.1 christos The public key to include can be given with the B<-force_pubkey> option 132 1.1 christos and defaults to the key given with the B<-key> (or B<-signkey>) option, 133 1.1 christos which implies self-signature. 134 1.1 christos 135 1.1 christos =item B<-x509toreq> 136 1.1 christos 137 1.1 christos Output a PKCS#10 certificate request (rather than a certificate). 138 1.1 christos The B<-key> (or B<-signkey>) option must be used to provide the private key for 139 1.1 christos self-signing; the corresponding public key is placed in the subjectPKInfo field. 140 1.1 christos 141 1.1 christos X.509 extensions included in a certificate input are not copied by default. 142 1.1 christos X.509 extensions to be added can be specified using the B<-extfile> option. 143 1.1 christos 144 1.1 christos =item B<-req> 145 1.1 christos 146 1.1 christos By default a certificate is expected on input. 147 1.1 christos With this option a PKCS#10 certificate request is expected instead, 148 1.1 christos which must be correctly self-signed. 149 1.1 christos 150 1.1 christos X.509 extensions included in the request are not copied by default. 151 1.1 christos X.509 extensions to be added can be specified using the B<-extfile> option. 152 1.1 christos 153 1.1 christos =item B<-copy_extensions> I<arg> 154 1.1 christos 155 1.1 christos Determines how to handle X.509 extensions 156 1.1 christos when converting from a certificate to a request using the B<-x509toreq> option 157 1.1 christos or converting from a request to a certificate using the B<-req> option. 158 1.1 christos If I<arg> is B<none> or this option is not present then extensions are ignored. 159 1.1 christos If I<arg> is B<copy> or B<copyall> then all extensions are copied, 160 1.1 christos except that subject identifier and authority key identifier extensions 161 1.1 christos are not taken over when producing a certificate request. 162 1.1 christos 163 1.1 christos The B<-ext> option can be used to further restrict which extensions to copy. 164 1.1 christos 165 1.1 christos =item B<-inform> B<DER>|B<PEM> 166 1.1 christos 167 1.1 christos The input file format to use; by default PEM is tried first. 168 1.1 christos See L<openssl-format-options(1)> for details. 169 1.1 christos 170 1.1 christos =item B<-vfyopt> I<nm>:I<v> 171 1.1 christos 172 1.1 christos Pass options to the signature algorithm during verify operations. 173 1.1 christos Names and values of these options are algorithm-specific. 174 1.1 christos 175 1.1 christos =item B<-key> I<filename>|I<uri> 176 1.1 christos 177 1.1 christos This option provides the private key for signing a new certificate or 178 1.1 christos certificate request. 179 1.1 christos Unless B<-force_pubkey> is given, the corresponding public key is placed in 180 1.1 christos the new certificate or certificate request, resulting in a self-signature. 181 1.1 christos 182 1.1 christos This option cannot be used in conjunction with the B<-CA> option. 183 1.1 christos 184 1.1 christos It sets the issuer name to the subject name (i.e., makes it self-issued). 185 1.1 christos Unless the B<-preserve_dates> option is supplied, 186 1.1 christos it sets the validity start date to the current time 187 1.1 christos and the end date to a value determined by the B<-days> option. 188 1.1 christos Start date and end date can also be explicitly supplied with options 189 1.1 christos B<-not_before> and B<-not_after>. 190 1.1 christos 191 1.1 christos =item B<-signkey> I<filename>|I<uri> 192 1.1 christos 193 1.1 christos This option is an alias of B<-key>. 194 1.1 christos 195 1.1 christos =item B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE> 196 1.1 christos 197 1.1 christos The key input format; unspecified by default. 198 1.1 christos See L<openssl-format-options(1)> for details. 199 1.1 christos 200 1.1 christos =item B<-out> I<filename> 201 1.1 christos 202 1.1 christos This specifies the output filename to write to or standard output by default. 203 1.1 christos 204 1.1 christos =item B<-outform> B<DER>|B<PEM> 205 1.1 christos 206 1.1 christos The output format; the default is B<PEM>. 207 1.1 christos See L<openssl-format-options(1)> for details. 208 1.1 christos 209 1.1 christos =item B<-nocert> 210 1.1 christos 211 1.1 christos Do not output a certificate (except for printing as requested by below options). 212 1.1 christos 213 1.1 christos =item B<-noout> 214 1.1 christos 215 1.1 christos This option prevents output except for printing as requested by below options. 216 1.1 christos 217 1.1 christos =back 218 1.1 christos 219 1.1 christos =head2 Certificate Printing Options 220 1.1 christos 221 1.1 christos Note: the B<-alias> and B<-purpose> options are also printing options 222 1.1 christos but are described in the L</Trust Settings> section. 223 1.1 christos 224 1.1 christos =over 4 225 1.1 christos 226 1.1 christos =item B<-dateopt> 227 1.1 christos 228 1.1 christos Specify the date output format. Values are: rfc_822 and iso_8601. 229 1.1 christos Defaults to rfc_822. 230 1.1 christos 231 1.1 christos =item B<-text> 232 1.1 christos 233 1.1 christos Prints out the certificate in text form. Full details are printed including the 234 1.1 christos public key, signature algorithms, issuer and subject names, serial number 235 1.1 christos any extensions present and any trust settings. 236 1.1 christos 237 1.1 christos =item B<-certopt> I<option> 238 1.1 christos 239 1.1 christos Customise the print format used with B<-text>. The I<option> argument 240 1.1 christos can be a single option or multiple options separated by commas. 241 1.1 christos The B<-certopt> switch may be also be used more than once to set multiple 242 1.1 christos options. See the L</Text Printing Flags> section for more information. 243 1.1 christos 244 1.1 christos =item B<-fingerprint> 245 1.1 christos 246 1.1 christos Calculates and prints the digest of the DER encoded version of the entire 247 1.1 christos certificate (see digest options). 248 1.1 christos This is commonly called a "fingerprint". Because of the nature of message 249 1.1 christos digests, the fingerprint of a certificate is unique to that certificate and 250 1.1 christos two certificates with the same fingerprint can be considered to be the same. 251 1.1 christos 252 1.1 christos =item B<-alias> 253 1.1 christos 254 1.1 christos Prints the certificate "alias" (nickname), if any. 255 1.1 christos 256 1.1 christos =item B<-serial> 257 1.1 christos 258 1.1 christos Prints the certificate serial number. 259 1.1 christos 260 1.1 christos =item B<-startdate> 261 1.1 christos 262 1.1 christos Prints out the start date of the certificate, that is the notBefore date. 263 1.1 christos 264 1.1 christos =item B<-enddate> 265 1.1 christos 266 1.1 christos Prints out the expiry date of the certificate, that is the notAfter date. 267 1.1 christos 268 1.1 christos =item B<-dates> 269 1.1 christos 270 1.1 christos Prints out the start and expiry dates of a certificate. 271 1.1 christos 272 1.1 christos =item B<-subject> 273 1.1 christos 274 1.1 christos Prints the subject name. 275 1.1 christos 276 1.1 christos =item B<-issuer> 277 1.1 christos 278 1.1 christos Prints the issuer name. 279 1.1 christos 280 1.1 christos {- $OpenSSL::safe::opt_name_item -} 281 1.1 christos 282 1.1 christos =item B<-email> 283 1.1 christos 284 1.1 christos Prints the email address(es) if any. 285 1.1 christos 286 1.1 christos =item B<-hash> 287 1.1 christos 288 1.1 christos Synonym for "-subject_hash" for backward compatibility reasons. 289 1.1 christos 290 1.1 christos =item B<-subject_hash> 291 1.1 christos 292 1.1 christos Prints the "hash" of the certificate subject name. This is used in OpenSSL to 293 1.1 christos form an index to allow certificates in a directory to be looked up by subject 294 1.1 christos name. 295 1.1 christos 296 1.1 christos =item B<-subject_hash_old> 297 1.1 christos 298 1.1 christos Prints the "hash" of the certificate subject name using the older algorithm 299 1.1 christos as used by OpenSSL before version 1.0.0. 300 1.1 christos 301 1.1 christos =item B<-issuer_hash> 302 1.1 christos 303 1.1 christos Prints the "hash" of the certificate issuer name. 304 1.1 christos 305 1.1 christos =item B<-issuer_hash_old> 306 1.1 christos 307 1.1 christos Prints the "hash" of the certificate issuer name using the older algorithm 308 1.1 christos as used by OpenSSL before version 1.0.0. 309 1.1 christos 310 1.1 christos =item B<-ext> I<extensions> 311 1.1 christos 312 1.1 christos Prints out the certificate extensions in text form. 313 1.1 christos Can also be used to restrict which extensions to copy. 314 1.1 christos Extensions are specified 315 1.1 christos with a comma separated string, e.g., "subjectAltName, subjectKeyIdentifier". 316 1.1 christos See the L<x509v3_config(5)> manual page for the extension names. 317 1.1 christos 318 1.1 christos =item B<-ocspid> 319 1.1 christos 320 1.1 christos Prints the OCSP hash values for the subject name and public key. 321 1.1 christos 322 1.1 christos =item B<-ocsp_uri> 323 1.1 christos 324 1.1 christos Prints the OCSP responder address(es) if any. 325 1.1 christos 326 1.1 christos =item B<-purpose> 327 1.1 christos 328 1.1 christos This option performs tests on the certificate extensions and outputs 329 1.1 christos the results. For a more complete description see 330 1.1 christos L<openssl-verification-options(1)/Certificate Extensions>. 331 1.1 christos 332 1.1 christos =item B<-pubkey> 333 1.1 christos 334 1.1 christos Prints the certificate's SubjectPublicKeyInfo block in PEM format. 335 1.1 christos 336 1.1 christos =item B<-modulus> 337 1.1 christos 338 1.1 christos This option prints out the value of the modulus of the public key 339 1.1 christos contained in the certificate. 340 1.1 christos 341 1.1 christos =back 342 1.1 christos 343 1.1 christos =head2 Certificate Checking Options 344 1.1 christos 345 1.1 christos =over 4 346 1.1 christos 347 1.1 christos =item B<-checkend> I<arg> 348 1.1 christos 349 1.1 christos Checks if the certificate expires within the next I<arg> seconds and exits 350 1.1 christos nonzero if yes it will expire or zero if not. 351 1.1 christos 352 1.1 christos =item B<-checkhost> I<host> 353 1.1 christos 354 1.1 christos Check that the certificate matches the specified host. 355 1.1 christos 356 1.1 christos =item B<-checkemail> I<email> 357 1.1 christos 358 1.1 christos Check that the certificate matches the specified email address. 359 1.1 christos 360 1.1 christos =item B<-checkip> I<ipaddr> 361 1.1 christos 362 1.1 christos Check that the certificate matches the specified IP address. 363 1.1 christos 364 1.1 christos =back 365 1.1 christos 366 1.1 christos =head2 Certificate Output Options 367 1.1 christos 368 1.1 christos =over 4 369 1.1 christos 370 1.1 christos =item B<-set_serial> I<n> 371 1.1 christos 372 1.1 christos Specifies the serial number to use. 373 1.1 christos This option can be used with the B<-key>, B<-signkey>, or B<-CA> options. 374 1.1 christos If used in conjunction with the B<-CA> option 375 1.1 christos the serial number file (as specified by the B<-CAserial> option) is not used. 376 1.1 christos 377 1.1 christos The serial number can be decimal or hex (if preceded by C<0x>). 378 1.1 christos 379 1.1 christos =item B<-next_serial> 380 1.1 christos 381 1.1 christos Set the serial to be one more than the number in the certificate. 382 1.1 christos 383 1.1 christos =item B<-not_before> I<date> 384 1.1 christos 385 1.1 christos This allows the start date to be explicitly set. The format of the 386 1.1 christos date is YYMMDDHHMMSSZ (the same as an ASN1 UTCTime structure), or 387 1.1 christos YYYYMMDDHHMMSSZ (the same as an ASN1 GeneralizedTime structure). In 388 1.1 christos both formats, seconds SS and timezone Z must be present. 389 1.1 christos Alternatively, you can also use "today". 390 1.1 christos 391 1.1 christos Cannot be used together with the B<-preserve_dates> option. 392 1.1 christos 393 1.1 christos =item B<-not_after> I<date> 394 1.1 christos 395 1.1 christos This allows the expiry date to be explicitly set. The format of the 396 1.1 christos date is YYMMDDHHMMSSZ (the same as an ASN1 UTCTime structure), or 397 1.1 christos YYYYMMDDHHMMSSZ (the same as an ASN1 GeneralizedTime structure). In 398 1.1 christos both formats, seconds SS and timezone Z must be present. 399 1.1 christos Alternatively, you can also use "today". 400 1.1 christos 401 1.1 christos Cannot be used together with the B<-preserve_dates> option. 402 1.1 christos This overrides the option B<-days>. 403 1.1 christos 404 1.1 christos =item B<-days> I<arg> 405 1.1 christos 406 1.1 christos Specifies the number of days from today until a newly generated certificate expires. 407 1.1 christos The default is 30. 408 1.1 christos 409 1.1 christos Cannot be used together with the option B<-preserve_dates>. 410 1.1 christos If option B<-not_after> is set, the explicit expiry date takes precedence. 411 1.1 christos 412 1.1 christos =item B<-preserve_dates> 413 1.1 christos 414 1.1 christos When signing a certificate, preserve "notBefore" and "notAfter" dates of any 415 1.1 christos input certificate instead of adjusting them to current time and duration. 416 1.1 christos Cannot be used together with the options B<-days>, B<-not_before> and B<-not_after>. 417 1.1 christos 418 1.1 christos =item B<-set_issuer> I<arg> 419 1.1 christos 420 1.1 christos When a certificate is created set its issuer name to the given value. 421 1.1 christos 422 1.1 christos See B<-set_subject> on how the arg must be formatted. 423 1.1 christos 424 1.1 christos =item B<-set_subject> I<arg> 425 1.1 christos 426 1.1 christos When a certificate is created set its subject name to the given value. 427 1.1 christos When the certificate is self-signed the issuer name is set to the same value, 428 1.1 christos unless the B<-set_issuer> option is given. 429 1.1 christos 430 1.1 christos The arg must be formatted as C</type0=value0/type1=value1/type2=...>. 431 1.1 christos Special characters may be escaped by C<\> (backslash), whitespace is retained. 432 1.1 christos Empty values are permitted, but the corresponding type will not be included 433 1.1 christos in the certificate. 434 1.1 christos Giving a single C</> will lead to an empty sequence of RDNs (a NULL-DN). 435 1.1 christos Multi-valued RDNs can be formed by placing a C<+> character instead of a C</> 436 1.1 christos between the AttributeValueAssertions (AVAs) that specify the members of the set. 437 1.1 christos Example: 438 1.1 christos 439 1.1 christos C</DC=org/DC=OpenSSL/DC=users/UID=123456+CN=John Doe> 440 1.1 christos 441 1.1 christos This option can be used with the B<-new> and B<-force_pubkey> options to create 442 1.1 christos a new certificate without providing an input certificate or certificate request. 443 1.1 christos 444 1.1 christos =item B<-subj> I<arg> 445 1.1 christos 446 1.1 christos This option is an alias of B<-set_subject>. 447 1.1 christos 448 1.1 christos =item B<-force_pubkey> I<filename> 449 1.1 christos 450 1.1 christos When a new certificate or certificate request is created 451 1.1 christos set its public key to the given key 452 1.1 christos instead of the key contained in the input 453 1.1 christos or given with the B<-key> (or B<-signkey>) option. 454 1.1 christos If the input contains no public key but a private key, its public part is used. 455 1.1 christos 456 1.1 christos This option can be used in conjunction with b<-new> and B<-set_subject> 457 1.1 christos to directly generate a certificate containing any desired public key. 458 1.1 christos 459 1.1 christos This option is also useful for creating self-issued certificates that are not 460 1.1 christos self-signed, for instance when the key cannot be used for signing, such as DH. 461 1.1 christos 462 1.1 christos =item B<-clrext> 463 1.1 christos 464 1.1 christos When transforming a certificate to a new certificate 465 1.1 christos by default all certificate extensions are retained. 466 1.1 christos 467 1.1 christos When transforming a certificate or certificate request, 468 1.1 christos the B<-clrext> option prevents taking over any extensions from the source. 469 1.1 christos In any case, when producing a certificate request, 470 1.1 christos neither subject identifier nor authority key identifier extensions are included. 471 1.1 christos 472 1.1 christos =item B<-extfile> I<filename> 473 1.1 christos 474 1.1 christos Configuration file containing certificate and request X.509 extensions to add. 475 1.1 christos 476 1.1 christos =item B<-extensions> I<section> 477 1.1 christos 478 1.1 christos The section in the extfile to add X.509 extensions from. 479 1.1 christos If this option is not 480 1.1 christos specified then the extensions should either be contained in the unnamed 481 1.1 christos (default) section or the default section should contain a variable called 482 1.1 christos "extensions" which contains the section to use. 483 1.1 christos 484 1.1 christos See the L<x509v3_config(5)> manual page for details of the 485 1.1 christos extension section format. 486 1.1 christos 487 1.1 christos Unless specified otherwise, 488 1.1 christos key identifier extensions are included as described in L<x509v3_config(5)>. 489 1.1 christos 490 1.1 christos =item B<-sigopt> I<nm>:I<v> 491 1.1 christos 492 1.1 christos Pass options to the signature algorithm during sign operations. 493 1.1 christos This option may be given multiple times. 494 1.1 christos Names and values provided using this option are algorithm-specific. 495 1.1 christos 496 1.1 christos =item B<-badsig> 497 1.1 christos 498 1.1 christos Corrupt the signature before writing it; this can be useful 499 1.1 christos for testing. 500 1.1 christos 501 1.1 christos =item B<-I<digest>> 502 1.1 christos 503 1.1 christos The digest to use. 504 1.1 christos This affects any signing or printing option that uses a message 505 1.1 christos digest, such as the B<-fingerprint>, B<-key>, and B<-CA> options. 506 1.1 christos Any digest supported by the L<openssl-dgst(1)> command can be used. 507 1.1 christos If not specified then SHA1 is used with B<-fingerprint> or 508 1.1 christos the default digest for the signing algorithm is used, typically SHA256. 509 1.1 christos 510 1.1 christos =back 511 1.1 christos 512 1.1 christos =head2 Micro-CA Options 513 1.1 christos 514 1.1 christos =over 4 515 1.1 christos 516 1.1 christos =item B<-CA> I<filename>|I<uri> 517 1.1 christos 518 1.1 christos Specifies the "CA" certificate to be used for signing. 519 1.1 christos When present, this behaves like a "micro CA" as follows: 520 1.1 christos The subject name of the "CA" certificate is placed as issuer name in the new 521 1.1 christos certificate, which is then signed using the "CA" key given as detailed below. 522 1.1 christos 523 1.1 christos This option cannot be used in conjunction with B<-key> (or B<-signkey>). 524 1.1 christos This option is normally combined with the B<-req> option referencing a CSR. 525 1.1 christos Without the B<-req> option the input must be an existing certificate 526 1.1 christos unless the B<-new> option is given, which generates a certificate from scratch. 527 1.1 christos 528 1.1 christos =item B<-CAform> B<DER>|B<PEM>|B<P12>, 529 1.1 christos 530 1.1 christos The format for the CA certificate; unspecified by default. 531 1.1 christos See L<openssl-format-options(1)> for details. 532 1.1 christos 533 1.1 christos =item B<-CAkey> I<filename>|I<uri> 534 1.1 christos 535 1.1 christos Sets the CA private key to sign a certificate with. 536 1.1 christos The private key must match the public key of the certificate given with B<-CA>. 537 1.1 christos If this option is not provided then the key must be present in the B<-CA> input. 538 1.1 christos 539 1.1 christos =item B<-CAkeyform> B<DER>|B<PEM>|B<P12>|B<ENGINE> 540 1.1 christos 541 1.1 christos The format for the CA key; unspecified by default. 542 1.1 christos See L<openssl-format-options(1)> for details. 543 1.1 christos 544 1.1 christos =item B<-CAserial> I<filename> 545 1.1 christos 546 1.1 christos Sets the CA serial number file to use. 547 1.1 christos 548 1.1 christos When creating a certificate with this option and with the B<-CA> option, 549 1.1 christos the certificate serial number is stored in the given file. 550 1.1 christos This file consists of one line containing 551 1.1 christos an even number of hex digits with the serial number used last time. 552 1.1 christos After reading this number, it is incremented and used, and the file is updated. 553 1.1 christos 554 1.1 christos The default filename consists of the CA certificate file base name with 555 1.1 christos F<.srl> appended. For example if the CA certificate file is called 556 1.1 christos F<mycacert.pem> it expects to find a serial number file called 557 1.1 christos F<mycacert.srl>. 558 1.1 christos 559 1.1 christos If the B<-CA> option is specified and neither <-CAserial> or <-CAcreateserial> 560 1.1 christos is given and the default serial number file does not exist, 561 1.1 christos a random number is generated; this is the recommended practice. 562 1.1 christos 563 1.1 christos =item B<-CAcreateserial> 564 1.1 christos 565 1.1 christos With this option and the B<-CA> option 566 1.1 christos the CA serial number file is created if it does not exist. 567 1.1 christos A random number is generated, used for the certificate, 568 1.1 christos and saved into the serial number file determined as described above. 569 1.1 christos 570 1.1 christos =back 571 1.1 christos 572 1.1 christos =head2 Trust Settings 573 1.1 christos 574 1.1 christos A B<trusted certificate> is an ordinary certificate which has several 575 1.1 christos additional pieces of information attached to it such as the permitted 576 1.1 christos and prohibited uses of the certificate and possibly an "alias" (nickname). 577 1.1 christos 578 1.1 christos Normally when a certificate is being verified at least one certificate 579 1.1 christos must be "trusted". By default a trusted certificate must be stored 580 1.1 christos locally and must be a root CA: any certificate chain ending in this CA 581 1.1 christos is then usable for any purpose. 582 1.1 christos 583 1.1 christos Trust settings currently are only used with a root CA. 584 1.1 christos They allow a finer control over the purposes the root CA can be used for. 585 1.1 christos For example, a CA may be trusted for SSL client but not SSL server use. 586 1.1 christos 587 1.1 christos See L<openssl-verification-options(1)> for more information 588 1.1 christos on the meaning of trust settings. 589 1.1 christos 590 1.1 christos Future versions of OpenSSL will recognize trust settings on any 591 1.1 christos certificate: not just root CAs. 592 1.1 christos 593 1.1 christos =over 4 594 1.1 christos 595 1.1 christos =item B<-trustout> 596 1.1 christos 597 1.1 christos Mark any certificate PEM output as <trusted> certificate rather than ordinary. 598 1.1 christos An ordinary or trusted certificate can be input but by default an ordinary 599 1.1 christos certificate is output and any trust settings are discarded. 600 1.1 christos With the B<-trustout> option a trusted certificate is output. A trusted 601 1.1 christos certificate is automatically output if any trust settings are modified. 602 1.1 christos 603 1.1 christos =item B<-setalias> I<arg> 604 1.1 christos 605 1.1 christos Sets the "alias" of the certificate. This will allow the certificate 606 1.1 christos to be referred to using a nickname for example "Steve's Certificate". 607 1.1 christos 608 1.1 christos =item B<-clrtrust> 609 1.1 christos 610 1.1 christos Clears all the permitted or trusted uses of the certificate. 611 1.1 christos 612 1.1 christos =item B<-addtrust> I<arg> 613 1.1 christos 614 1.1 christos Adds a trusted certificate use. 615 1.1 christos Any object name can be used here but currently only B<clientAuth>, 616 1.1 christos B<serverAuth>, B<emailProtection>, and B<anyExtendedKeyUsage> are defined. 617 1.1 christos As of OpenSSL 1.1.0, the last of these blocks all purposes when rejected or 618 1.1 christos enables all purposes when trusted. 619 1.1 christos Other OpenSSL applications may define additional uses. 620 1.1 christos 621 1.1 christos =item B<-clrreject> 622 1.1 christos 623 1.1 christos Clears all the prohibited or rejected uses of the certificate. 624 1.1 christos 625 1.1 christos =item B<-addreject> I<arg> 626 1.1 christos 627 1.1 christos Adds a prohibited trust anchor purpose. 628 1.1 christos It accepts the same values as the B<-addtrust> option. 629 1.1 christos 630 1.1 christos =back 631 1.1 christos 632 1.1 christos =head2 Generic options 633 1.1 christos 634 1.1 christos =over 4 635 1.1 christos 636 1.1 christos {- $OpenSSL::safe::opt_r_item -} 637 1.1 christos 638 1.1 christos {- $OpenSSL::safe::opt_engine_item -} 639 1.1 christos 640 1.1 christos {- $OpenSSL::safe::opt_provider_item -} 641 1.1 christos 642 1.1 christos =back 643 1.1 christos 644 1.1 christos =head2 Text Printing Flags 645 1.1 christos 646 1.1 christos As well as customising the name printing format, it is also possible to 647 1.1 christos customise the actual fields printed using the B<certopt> option when 648 1.1 christos the B<text> option is present. The default behaviour is to print all fields. 649 1.1 christos 650 1.1 christos =over 4 651 1.1 christos 652 1.1 christos =item B<compatible> 653 1.1 christos 654 1.1 christos Use the old format. This is equivalent to specifying no printing options at all. 655 1.1 christos 656 1.1 christos =item B<no_header> 657 1.1 christos 658 1.1 christos Don't print header information: that is the lines saying "Certificate" 659 1.1 christos and "Data". 660 1.1 christos 661 1.1 christos =item B<no_version> 662 1.1 christos 663 1.1 christos Don't print out the version number. 664 1.1 christos 665 1.1 christos =item B<no_serial> 666 1.1 christos 667 1.1 christos Don't print out the serial number. 668 1.1 christos 669 1.1 christos =item B<no_signame> 670 1.1 christos 671 1.1 christos Don't print out the signature algorithm used. 672 1.1 christos 673 1.1 christos =item B<no_validity> 674 1.1 christos 675 1.1 christos Don't print the validity, that is the B<notBefore> and B<notAfter> fields. 676 1.1 christos 677 1.1 christos =item B<no_subject> 678 1.1 christos 679 1.1 christos Don't print out the subject name. 680 1.1 christos 681 1.1 christos =item B<no_issuer> 682 1.1 christos 683 1.1 christos Don't print out the issuer name. 684 1.1 christos 685 1.1 christos =item B<no_pubkey> 686 1.1 christos 687 1.1 christos Don't print out the public key. 688 1.1 christos 689 1.1 christos =item B<no_sigdump> 690 1.1 christos 691 1.1 christos Don't give a hexadecimal dump of the certificate signature. 692 1.1 christos 693 1.1 christos =item B<no_aux> 694 1.1 christos 695 1.1 christos Don't print out certificate trust information. 696 1.1 christos 697 1.1 christos =item B<no_extensions> 698 1.1 christos 699 1.1 christos Don't print out any X509V3 extensions. 700 1.1 christos 701 1.1 christos =item B<ext_default> 702 1.1 christos 703 1.1 christos Retain default extension behaviour: attempt to print out unsupported 704 1.1 christos certificate extensions. 705 1.1 christos 706 1.1 christos =item B<ext_error> 707 1.1 christos 708 1.1 christos Print an error message for unsupported certificate extensions. 709 1.1 christos 710 1.1 christos =item B<ext_parse> 711 1.1 christos 712 1.1 christos ASN1 parse unsupported extensions. 713 1.1 christos 714 1.1 christos =item B<ext_dump> 715 1.1 christos 716 1.1 christos Hex dump unsupported extensions. 717 1.1 christos 718 1.1 christos =item B<ca_default> 719 1.1 christos 720 1.1 christos The value used by L<openssl-ca(1)>, equivalent to B<no_issuer>, B<no_pubkey>, 721 1.1 christos B<no_header>, and B<no_version>. 722 1.1 christos 723 1.1 christos =back 724 1.1 christos 725 1.1 christos =head1 EXAMPLES 726 1.1 christos 727 1.1 christos Note: in these examples the '\' means the example should be all on one 728 1.1 christos line. 729 1.1 christos 730 1.1 christos Print the contents of a certificate: 731 1.1 christos 732 1.1 christos openssl x509 -in cert.pem -noout -text 733 1.1 christos 734 1.1 christos Print the "Subject Alternative Name" extension of a certificate: 735 1.1 christos 736 1.1 christos openssl x509 -in cert.pem -noout -ext subjectAltName 737 1.1 christos 738 1.1 christos Print more extensions of a certificate: 739 1.1 christos 740 1.1 christos openssl x509 -in cert.pem -noout -ext subjectAltName,nsCertType 741 1.1 christos 742 1.1 christos Print the certificate serial number: 743 1.1 christos 744 1.1 christos openssl x509 -in cert.pem -noout -serial 745 1.1 christos 746 1.1 christos Print the certificate subject name: 747 1.1 christos 748 1.1 christos openssl x509 -in cert.pem -noout -subject 749 1.1 christos 750 1.1 christos Print the certificate subject name in RFC2253 form: 751 1.1 christos 752 1.1 christos openssl x509 -in cert.pem -noout -subject -nameopt RFC2253 753 1.1 christos 754 1.1 christos Print the certificate subject name in oneline form on a terminal 755 1.1 christos supporting UTF8: 756 1.1 christos 757 1.1 christos openssl x509 -in cert.pem -noout -subject -nameopt oneline,-esc_msb 758 1.1 christos 759 1.1 christos Print the certificate SHA1 fingerprint: 760 1.1 christos 761 1.1 christos openssl x509 -sha1 -in cert.pem -noout -fingerprint 762 1.1 christos 763 1.1 christos Convert a certificate from PEM to DER format: 764 1.1 christos 765 1.1 christos openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER 766 1.1 christos 767 1.1 christos Convert a certificate to a certificate request: 768 1.1 christos 769 1.1 christos openssl x509 -x509toreq -in cert.pem -out req.pem -key key.pem 770 1.1 christos 771 1.1 christos Convert a certificate request into a self-signed certificate using 772 1.1 christos extensions for a CA: 773 1.1 christos 774 1.1 christos openssl x509 -req -in careq.pem -extfile openssl.cnf -extensions v3_ca \ 775 1.1 christos -key key.pem -out cacert.pem 776 1.1 christos 777 1.1 christos Sign a certificate request using the CA certificate above and add user 778 1.1 christos certificate extensions: 779 1.1 christos 780 1.1 christos openssl x509 -req -in req.pem -extfile openssl.cnf -extensions v3_usr \ 781 1.1 christos -CA cacert.pem -CAkey key.pem -CAcreateserial 782 1.1 christos 783 1.1 christos Set a certificate to be trusted for SSL client use and change set its alias to 784 1.1 christos "Steve's Class 1 CA" 785 1.1 christos 786 1.1 christos openssl x509 -in cert.pem -addtrust clientAuth \ 787 1.1 christos -setalias "Steve's Class 1 CA" -out trust.pem 788 1.1 christos 789 1.1 christos =head1 NOTES 790 1.1 christos 791 1.1 christos The conversion to UTF8 format used with the name options assumes that 792 1.1 christos T61Strings use the ISO8859-1 character set. This is wrong but Netscape 793 1.1 christos and MSIE do this as do many certificates. So although this is incorrect 794 1.1 christos it is more likely to print the majority of certificates correctly. 795 1.1 christos 796 1.1 christos The B<-email> option searches the subject name and the subject alternative 797 1.1 christos name extension. Only unique email addresses will be printed out: it will 798 1.1 christos not print the same address more than once. 799 1.1 christos 800 1.1 christos =head1 BUGS 801 1.1 christos 802 1.1 christos It is possible to produce invalid certificates or requests by specifying the 803 1.1 christos wrong private key, using unsuitable X.509 extensions, 804 1.1 christos or using inconsistent options in some cases: these should be checked. 805 1.1 christos 806 1.1 christos There should be options to explicitly set such things as start and end 807 1.1 christos dates rather than an offset from the current time. 808 1.1 christos 809 1.1 christos =head1 SEE ALSO 810 1.1 christos 811 1.1 christos L<openssl(1)>, 812 1.1 christos L<openssl-req(1)>, 813 1.1 christos L<openssl-ca(1)>, 814 1.1 christos L<openssl-genrsa(1)>, 815 1.1 christos L<openssl-gendsa(1)>, 816 1.1 christos L<openssl-verify(1)>, 817 1.1 christos L<x509v3_config(5)> 818 1.1 christos 819 1.1 christos =head1 HISTORY 820 1.1 christos 821 1.1 christos The hash algorithm used in the B<-subject_hash> and B<-issuer_hash> options 822 1.1 christos before OpenSSL 1.0.0 was based on the deprecated MD5 algorithm and the encoding 823 1.1 christos of the distinguished name. In OpenSSL 1.0.0 and later it is based on a canonical 824 1.1 christos version of the DN using SHA1. This means that any directories using the old 825 1.1 christos form must have their links rebuilt using L<openssl-rehash(1)> or similar. 826 1.1 christos 827 1.1 christos The B<-signkey> option has been renamed to B<-key> in OpenSSL 3.0, 828 1.1 christos keeping the old name as an alias. 829 1.1 christos 830 1.1 christos The B<-engine> option was deprecated in OpenSSL 3.0. 831 1.1 christos 832 1.1 christos The B<-C> option was removed in OpenSSL 3.0. 833 1.1 christos 834 1.1 christos Since OpenSSL 3.2, generated certificates bear X.509 version 3, 835 1.1 christos and key identifier extensions are included by default. 836 1.1 christos 837 1.1 christos =head1 COPYRIGHT 838 1.1 christos 839 1.1 christos Copyright 2000-2024 The OpenSSL Project Authors. All Rights Reserved. 840 1.1 christos 841 1.1 christos Licensed under the Apache License 2.0 (the "License"). You may not use 842 1.1 christos this file except in compliance with the License. You can obtain a copy 843 1.1 christos in the file LICENSE in the source distribution or at 844 1.1 christos L<https://www.openssl.org/source/license.html>. 845 1.1 christos 846 1.1 christos =cut 847