2
0

openssl-x509.pod.in 23 KB

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