openssl-x509.pod.in 24 KB

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