A local copy of OpenSSL from GitHub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

944 lines
29 KiB

10 years ago
10 years ago
10 years ago
22 years ago
22 years ago
22 years ago
21 years ago
21 years ago
  1. =pod
  2. {- OpenSSL::safe::output_do_not_edit_headers(); -}
  3. =head1 NAME
  4. openssl-x509 - Certificate display and signing utility
  5. =head1 SYNOPSIS
  6. B<openssl> B<x509>
  7. [B<-help>]
  8. [B<-inform> B<DER>|B<PEM>]
  9. [B<-outform> B<DER>|B<PEM>]
  10. [B<-keyform> B<DER>|B<PEM>|B<ENGINE>]
  11. [B<-CAform> B<DER>|B<PEM>]
  12. [B<-CAkeyform> B<DER>|B<PEM>|B<ENGINE>]
  13. [B<-in> I<filename>]
  14. [B<-out> I<filename>]
  15. [B<-serial>]
  16. [B<-hash>]
  17. [B<-subject_hash>]
  18. [B<-issuer_hash>]
  19. [B<-ocspid>]
  20. [B<-subject>]
  21. [B<-issuer>]
  22. [B<-nameopt> I<option>]
  23. [B<-email>]
  24. [B<-ocsp_uri>]
  25. [B<-startdate>]
  26. [B<-enddate>]
  27. [B<-purpose>]
  28. [B<-dates>]
  29. [B<-checkend> I<num>]
  30. [B<-modulus>]
  31. [B<-pubkey>]
  32. [B<-fingerprint>]
  33. [B<-alias>]
  34. [B<-noout>]
  35. [B<-trustout>]
  36. [B<-clrtrust>]
  37. [B<-clrreject>]
  38. [B<-addtrust> I<arg>]
  39. [B<-addreject> I<arg>]
  40. [B<-setalias> I<arg>]
  41. [B<-days> I<arg>]
  42. [B<-set_serial> I<n>]
  43. [B<-signkey> I<filename>]
  44. [B<-passin> I<arg>]
  45. [B<-x509toreq>]
  46. [B<-req>]
  47. [B<-CA> I<filename>]
  48. [B<-CAkey> I<filename>]
  49. [B<-CAcreateserial>]
  50. [B<-CAserial> I<filename>]
  51. [B<-new>]
  52. [B<-force_pubkey> I<filename>]
  53. [B<-subj> I<arg>]
  54. [B<-text>]
  55. [B<-ext> I<extensions>]
  56. [B<-certopt> I<option>]
  57. [B<-C>]
  58. [B<-I<digest>>]
  59. [B<-clrext>]
  60. [B<-extfile> I<filename>]
  61. [B<-extensions> I<section>]
  62. [B<-sigopt> I<nm>:I<v>]
  63. [B<-engine> I<id>]
  64. [B<-preserve_dates>]
  65. {- $OpenSSL::safe::opt_r_synopsis -}
  66. =for openssl ifdef engine subject_hash_old issuer_hash_old
  67. =head1 DESCRIPTION
  68. This command is a multi purpose certificate utility. It can
  69. be used to display certificate information, convert certificates to
  70. various forms, sign certificate requests like a "mini CA" or edit
  71. certificate trust settings.
  72. Since there are a large number of options they will split up into
  73. various sections.
  74. =head1 OPTIONS
  75. =head2 Input, Output, and General Purpose Options
  76. =over 4
  77. =item B<-help>
  78. Print out a usage message.
  79. =item B<-inform> B<DER>|B<PEM>, B<-outform> B<DER>|B<PEM>
  80. The input and formats; the default is B<PEM>.
  81. See L<openssl(1)/Format Options> for details.
  82. The input is normally an X.509 certificate, but this can change if other
  83. options such as B<-req> are used.
  84. =item B<-in> I<filename>
  85. This specifies the input filename to read a certificate from or standard input
  86. if this option is not specified.
  87. =item B<-out> I<filename>
  88. This specifies the output filename to write to or standard output by
  89. default.
  90. =item B<-I<digest>>
  91. The digest to use.
  92. This affects any signing or display option that uses a message
  93. digest, such as the B<-fingerprint>, B<-signkey> and B<-CA> options.
  94. Any digest supported by the L<openssl-dgst(1)> command can be used.
  95. If not specified then SHA1 is used with B<-fingerprint> or
  96. the default digest for the signing algorithm is used, typically SHA256.
  97. =item B<-engine> I<id>
  98. Specifying an engine (by its unique I<id> string) will cause this command
  99. to attempt to obtain a functional reference to the specified engine,
  100. thus initialising it if needed. The engine will then be set as the default
  101. for all available algorithms.
  102. =item B<-preserve_dates>
  103. When signing a certificate, preserve the "notBefore" and "notAfter" dates
  104. instead of adjusting them to current time and duration.
  105. Cannot be used with the B<-days> option.
  106. {- $OpenSSL::safe::opt_r_synopsis -}
  107. =back
  108. =head2 Display Options
  109. Note: the B<-alias> and B<-purpose> options are also display options
  110. but are described in the L</Trust Settings> section.
  111. =over 4
  112. =item B<-text>
  113. Prints out the certificate in text form. Full details are output including the
  114. public key, signature algorithms, issuer and subject names, serial number
  115. any extensions present and any trust settings.
  116. =item B<-ext> I<extensions>
  117. Prints out the certificate extensions in text form. Extensions are specified
  118. with a comma separated string, e.g., "subjectAltName,subjectKeyIdentifier".
  119. See the L<x509v3_config(5)> manual page for the extension names.
  120. =item B<-certopt> I<option>
  121. Customise the output format used with B<-text>. The I<option> argument
  122. can be a single option or multiple options separated by commas. The
  123. B<-certopt> switch may be also be used more than once to set multiple
  124. options. See the L</Text Options> section for more information.
  125. =item B<-noout>
  126. This option prevents output of the encoded version of the certificate.
  127. =item B<-pubkey>
  128. Outputs the certificate's SubjectPublicKeyInfo block in PEM format.
  129. =item B<-modulus>
  130. This option prints out the value of the modulus of the public key
  131. contained in the certificate.
  132. =item B<-serial>
  133. Outputs the certificate serial number.
  134. =item B<-subject_hash>
  135. Outputs the "hash" of the certificate subject name. This is used in OpenSSL to
  136. form an index to allow certificates in a directory to be looked up by subject
  137. name.
  138. =item B<-issuer_hash>
  139. Outputs the "hash" of the certificate issuer name.
  140. =item B<-ocspid>
  141. Outputs the OCSP hash values for the subject name and public key.
  142. =item B<-hash>
  143. Synonym for "-subject_hash" for backward compatibility reasons.
  144. =item B<-subject_hash_old>
  145. Outputs the "hash" of the certificate subject name using the older algorithm
  146. as used by OpenSSL before version 1.0.0.
  147. =item B<-issuer_hash_old>
  148. Outputs the "hash" of the certificate issuer name using the older algorithm
  149. as used by OpenSSL before version 1.0.0.
  150. =item B<-subject>
  151. Outputs the subject name.
  152. =item B<-issuer>
  153. Outputs the issuer name.
  154. =item B<-nameopt> I<option>
  155. Option which determines how the subject or issuer names are displayed. The
  156. I<option> argument can be a single option or multiple options separated by
  157. commas. Alternatively the B<-nameopt> switch may be used more than once to
  158. set multiple options. See the L</Name Options> section for more information.
  159. =item B<-email>
  160. Outputs the email address(es) if any.
  161. =item B<-ocsp_uri>
  162. Outputs the OCSP responder address(es) if any.
  163. =item B<-startdate>
  164. Prints out the start date of the certificate, that is the notBefore date.
  165. =item B<-enddate>
  166. Prints out the expiry date of the certificate, that is the notAfter date.
  167. =item B<-dates>
  168. Prints out the start and expiry dates of a certificate.
  169. =item B<-checkend> I<arg>
  170. Checks if the certificate expires within the next I<arg> seconds and exits
  171. nonzero if yes it will expire or zero if not.
  172. =item B<-fingerprint>
  173. Calculates and outputs the digest of the DER encoded version of the entire
  174. certificate (see digest options).
  175. This is commonly called a "fingerprint". Because of the nature of message
  176. digests, the fingerprint of a certificate is unique to that certificate and
  177. two certificates with the same fingerprint can be considered to be the same.
  178. =item B<-C>
  179. This outputs the certificate in the form of a C source file.
  180. =back
  181. =head2 Trust Settings
  182. A B<trusted certificate> is an ordinary certificate which has several
  183. additional pieces of information attached to it such as the permitted
  184. and prohibited uses of the certificate and an "alias".
  185. Normally when a certificate is being verified at least one certificate
  186. must be "trusted". By default a trusted certificate must be stored
  187. locally and must be a root CA: any certificate chain ending in this CA
  188. is then usable for any purpose.
  189. Trust settings currently are only used with a root CA. They allow a finer
  190. control over the purposes the root CA can be used for. For example a CA
  191. may be trusted for SSL client but not SSL server use.
  192. See the description in L<openssl-verify(1)> for more information
  193. on the meaning of trust settings.
  194. Future versions of OpenSSL will recognize trust settings on any
  195. certificate: not just root CAs.
  196. =over 4
  197. =item B<-trustout>
  198. Output a B<trusted> certificate rather than an ordinary. An ordinary
  199. or trusted certificate can be input but by default an ordinary
  200. certificate is output and any trust settings are discarded. With the
  201. B<-trustout> option a trusted certificate is output. A trusted
  202. certificate is automatically output if any trust settings are modified.
  203. =item B<-setalias> I<arg>
  204. Sets the alias of the certificate. This will allow the certificate
  205. to be referred to using a nickname for example "Steve's Certificate".
  206. =item B<-alias>
  207. Outputs the certificate alias, if any.
  208. =item B<-clrtrust>
  209. Clears all the permitted or trusted uses of the certificate.
  210. =item B<-clrreject>
  211. Clears all the prohibited or rejected uses of the certificate.
  212. =item B<-addtrust> I<arg>
  213. Adds a trusted certificate use.
  214. Any object name can be used here but currently only B<clientAuth> (SSL client
  215. use), B<serverAuth> (SSL server use), B<emailProtection> (S/MIME email) and
  216. B<anyExtendedKeyUsage> are used.
  217. As of OpenSSL 1.1.0, the last of these blocks all purposes when rejected or
  218. enables all purposes when trusted.
  219. Other OpenSSL applications may define additional uses.
  220. =item B<-addreject> I<arg>
  221. Adds a prohibited use. It accepts the same values as the B<-addtrust>
  222. option.
  223. =item B<-purpose>
  224. This option performs tests on the certificate extensions and outputs
  225. the results. For a more complete description see the
  226. L</CERTIFICATE EXTENSIONS> section.
  227. =back
  228. =head2 Signing Options
  229. This command can be used to sign certificates and requests: it
  230. can thus behave like a "mini CA".
  231. =over 4
  232. =item B<-signkey> I<filename>
  233. This option causes the input file to be self signed using the supplied
  234. private key.
  235. It sets the issuer name to the subject name (i.e., makes it self-issued)
  236. and changes the public key to the supplied value (unless overridden by
  237. B<-force_pubkey>). It sets the validity start date to the current time
  238. and the end date to a value determined by the B<-days> option.
  239. It retains any certificate extensions unless the B<-clrext> option is supplied;
  240. this includes, for example, any existing key identifier extensions.
  241. =item B<-sigopt> I<nm>:I<v>
  242. Pass options to the signature algorithm during sign or verify operations.
  243. Names and values of these options are algorithm-specific.
  244. =item B<-passin> I<arg>
  245. The key password source. For more information about the format of I<arg>
  246. see L<openssl(1)/Pass Phrase Options>.
  247. =item B<-clrext>
  248. Delete any extensions from a certificate. This option is used when a
  249. certificate is being created from another certificate (for example with
  250. the B<-signkey> or the B<-CA> options). Normally all extensions are
  251. retained.
  252. =item B<-keyform> B<DER>|B<PEM>
  253. The key format; the default is B<PEM>.
  254. See L<openssl(1)/Format Options> for details.
  255. =item B<-CAform> B<DER>|B<PEM>, B<-CAkeyform> B<DER>|B<PEM>
  256. The format for the CA certificate and key; the default is B<PEM>.
  257. See L<openssl(1)/Format Options> for details.
  258. =item B<-days> I<arg>
  259. Specifies the number of days to make a certificate valid for. The default
  260. is 30 days. Cannot be used with the B<-preserve_dates> option.
  261. =item B<-x509toreq>
  262. Converts a certificate into a certificate request. The B<-signkey> option
  263. is used to pass the required private key.
  264. =item B<-req>
  265. By default a certificate is expected on input. With this option a
  266. certificate request is expected instead.
  267. =item B<-set_serial> I<n>
  268. Specifies the serial number to use. This option can be used with either
  269. the B<-signkey> or B<-CA> options. If used in conjunction with the B<-CA>
  270. option the serial number file (as specified by the B<-CAserial> or
  271. B<-CAcreateserial> options) is not used.
  272. The serial number can be decimal or hex (if preceded by C<0x>).
  273. =item B<-CA> I<filename>
  274. Specifies the CA certificate to be used for signing. When this option is
  275. present, this command behaves like a "mini CA". The input file is signed by
  276. this CA using this option: that is its issuer name is set to the subject name
  277. of the CA and it is digitally signed using the CAs private key.
  278. This option is normally combined with the B<-req> option. Without the
  279. B<-req> option the input is a certificate which must be self signed.
  280. =item B<-CAkey> I<filename>
  281. Sets the CA private key to sign a certificate with. If this option is
  282. not specified then it is assumed that the CA private key is present in
  283. the CA certificate file.
  284. =item B<-CAserial> I<filename>
  285. Sets the CA serial number file to use.
  286. When the B<-CA> option is used to sign a certificate it uses a serial
  287. number specified in a file. This file consists of one line containing
  288. an even number of hex digits with the serial number to use. After each
  289. use the serial number is incremented and written out to the file again.
  290. The default filename consists of the CA certificate file base name with
  291. F<.srl> appended. For example if the CA certificate file is called
  292. F<mycacert.pem> it expects to find a serial number file called
  293. F<mycacert.srl>.
  294. =item B<-CAcreateserial>
  295. With this option the CA serial number file is created if it does not exist:
  296. it will contain the serial number "02" and the certificate being signed will
  297. have the 1 as its serial number. If the B<-CA> option is specified
  298. and the serial number file does not exist a random number is generated;
  299. this is the recommended practice.
  300. =item B<-extfile> I<filename>
  301. File containing certificate extensions to use. If not specified then
  302. no extensions are added to the certificate.
  303. =item B<-extensions> I<section>
  304. The section to add certificate extensions from. If this option is not
  305. specified then the extensions should either be contained in the unnamed
  306. (default) section or the default section should contain a variable called
  307. "extensions" which contains the section to use. See the
  308. L<x509v3_config(5)> manual page for details of the
  309. extension section format.
  310. =item B<-new>
  311. Generate a certificate from scratch, not using an input certificate
  312. or certificate request. So the B<-in> option must not be used in this case.
  313. Instead, the B<-subj> and <-force_pubkey> options need to be given.
  314. =item B<-force_pubkey> I<filename>
  315. When a certificate is created set its public key to the key in I<filename>
  316. instead of the key contained in the input or given with the B<-signkey> option.
  317. This option is useful for creating self-issued certificates that are not
  318. self-signed, for instance when the key cannot be used for signing, such as DH.
  319. It can also be used in conjunction with b<-new> and B<-subj> to directly
  320. generate a certificate containing any desired public key.
  321. The format of the key file can be specified using the B<-keyform> option.
  322. =item B<-subj> I<arg>
  323. When a certificate is created set its subject name to the given value.
  324. The arg must be formatted as C</type0=value0/type1=value1/type2=...>.
  325. Keyword characters may be escaped by \ (backslash), and whitespace is retained.
  326. Empty values are permitted, but the corresponding type will not be included
  327. in the certificate. Giving a single C</> will lead to an empty sequence of RDNs
  328. (a NULL subject DN).
  329. Unless the B<-CA> option is given the issuer is set to the same value.
  330. This option can be used in conjunction with the B<-force_pubkey> option
  331. to create a certificate even without providing an input certificate
  332. or certificate request.
  333. =back
  334. =head2 Name Options
  335. The B<-nameopt> command line switch determines how the subject and issuer
  336. names are displayed. If no B<-nameopt> switch is present the default "oneline"
  337. format is used which is compatible with previous versions of OpenSSL.
  338. Each option is described in detail below, all options can be preceded by
  339. a B<-> to turn the option off. Only the first four will normally be used.
  340. =over 4
  341. =item B<compat>
  342. Use the old format.
  343. =item B<RFC2253>
  344. Displays names compatible with RFC2253 equivalent to B<esc_2253>, B<esc_ctrl>,
  345. B<esc_msb>, B<utf8>, B<dump_nostr>, B<dump_unknown>, B<dump_der>,
  346. B<sep_comma_plus>, B<dn_rev> and B<sname>.
  347. =item B<oneline>
  348. A oneline format which is more readable than RFC2253. It is equivalent to
  349. specifying the B<esc_2253>, B<esc_ctrl>, B<esc_msb>, B<utf8>, B<dump_nostr>,
  350. B<dump_der>, B<use_quote>, B<sep_comma_plus_space>, B<space_eq> and B<sname>
  351. options. This is the I<default> of no name options are given explicitly.
  352. =item B<multiline>
  353. A multiline format. It is equivalent B<esc_ctrl>, B<esc_msb>, B<sep_multiline>,
  354. B<space_eq>, B<lname> and B<align>.
  355. =item B<esc_2253>
  356. Escape the "special" characters required by RFC2253 in a field. That is
  357. B<,+"E<lt>E<gt>;>. Additionally B<#> is escaped at the beginning of a string
  358. and a space character at the beginning or end of a string.
  359. =item B<esc_2254>
  360. Escape the "special" characters required by RFC2254 in a field. That is
  361. the B<NUL> character as well as and B<()*>.
  362. =item B<esc_ctrl>
  363. Escape control characters. That is those with ASCII values less than
  364. 0x20 (space) and the delete (0x7f) character. They are escaped using the
  365. RFC2253 \XX notation (where XX are two hex digits representing the
  366. character value).
  367. =item B<esc_msb>
  368. Escape characters with the MSB set, that is with ASCII values larger than
  369. 127.
  370. =item B<use_quote>
  371. Escapes some characters by surrounding the whole string with B<"> characters,
  372. without the option all escaping is done with the B<\> character.
  373. =item B<utf8>
  374. Convert all strings to UTF8 format first. This is required by RFC2253. If
  375. you are lucky enough to have a UTF8 compatible terminal then the use
  376. of this option (and B<not> setting B<esc_msb>) may result in the correct
  377. display of multibyte (international) characters. Is this option is not
  378. present then multibyte characters larger than 0xff will be represented
  379. using the format \UXXXX for 16 bits and \WXXXXXXXX for 32 bits.
  380. Also if this option is off any UTF8Strings will be converted to their
  381. character form first.
  382. =item B<ignore_type>
  383. This option does not attempt to interpret multibyte characters in any
  384. way. That is their content octets are merely dumped as though one octet
  385. represents each character. This is useful for diagnostic purposes but
  386. will result in rather odd looking output.
  387. =item B<show_type>
  388. Show the type of the ASN1 character string. The type precedes the
  389. field contents. For example "BMPSTRING: Hello World".
  390. =item B<dump_der>
  391. When this option is set any fields that need to be hexdumped will
  392. be dumped using the DER encoding of the field. Otherwise just the
  393. content octets will be displayed. Both options use the RFC2253
  394. B<#XXXX...> format.
  395. =item B<dump_nostr>
  396. Dump non character string types (for example OCTET STRING) if this
  397. option is not set then non character string types will be displayed
  398. as though each content octet represents a single character.
  399. =item B<dump_all>
  400. Dump all fields. This option when used with B<dump_der> allows the
  401. DER encoding of the structure to be unambiguously determined.
  402. =item B<dump_unknown>
  403. Dump any field whose OID is not recognised by OpenSSL.
  404. =item B<sep_comma_plus>, B<sep_comma_plus_space>, B<sep_semi_plus_space>,
  405. B<sep_multiline>
  406. These options determine the field separators. The first character is
  407. between Relative Distinguished Names (RDNs) and the second is between
  408. multiple Attribute Value Assertions (AVAs, multiple AVAs are
  409. very rare and their use is discouraged). The options ending in
  410. "space" additionally place a space after the separator to make it
  411. more readable. The B<sep_multiline> uses a linefeed character for
  412. the RDN separator and a spaced B<+> for the AVA separator. It also
  413. indents the fields by four characters. If no field separator is specified
  414. then B<sep_comma_plus_space> is used by default.
  415. =item B<dn_rev>
  416. Reverse the fields of the DN. This is required by RFC2253. As a side
  417. effect this also reverses the order of multiple AVAs but this is
  418. permissible.
  419. =item B<nofname>, B<sname>, B<lname>, B<oid>
  420. These options alter how the field name is displayed. B<nofname> does
  421. not display the field at all. B<sname> uses the "short name" form
  422. (CN for commonName for example). B<lname> uses the long form.
  423. B<oid> represents the OID in numerical form and is useful for
  424. diagnostic purpose.
  425. =item B<align>
  426. Align field values for a more readable output. Only usable with
  427. B<sep_multiline>.
  428. =item B<space_eq>
  429. Places spaces round the B<=> character which follows the field
  430. name.
  431. =back
  432. =head2 Text Options
  433. As well as customising the name output format, it is also possible to
  434. customise the actual fields printed using the B<certopt> options when
  435. the B<text> option is present. The default behaviour is to print all fields.
  436. =over 4
  437. =item B<compatible>
  438. Use the old format. This is equivalent to specifying no output options at all.
  439. =item B<no_header>
  440. Don't print header information: that is the lines saying "Certificate"
  441. and "Data".
  442. =item B<no_version>
  443. Don't print out the version number.
  444. =item B<no_serial>
  445. Don't print out the serial number.
  446. =item B<no_signame>
  447. Don't print out the signature algorithm used.
  448. =item B<no_validity>
  449. Don't print the validity, that is the B<notBefore> and B<notAfter> fields.
  450. =item B<no_subject>
  451. Don't print out the subject name.
  452. =item B<no_issuer>
  453. Don't print out the issuer name.
  454. =item B<no_pubkey>
  455. Don't print out the public key.
  456. =item B<no_sigdump>
  457. Don't give a hexadecimal dump of the certificate signature.
  458. =item B<no_aux>
  459. Don't print out certificate trust information.
  460. =item B<no_extensions>
  461. Don't print out any X509V3 extensions.
  462. =item B<ext_default>
  463. Retain default extension behaviour: attempt to print out unsupported
  464. certificate extensions.
  465. =item B<ext_error>
  466. Print an error message for unsupported certificate extensions.
  467. =item B<ext_parse>
  468. ASN1 parse unsupported extensions.
  469. =item B<ext_dump>
  470. Hex dump unsupported extensions.
  471. =item B<ca_default>
  472. The value used by L<openssl-ca(1)>, equivalent to B<no_issuer>, B<no_pubkey>,
  473. B<no_header>, and B<no_version>.
  474. =back
  475. =head1 EXAMPLES
  476. Note: in these examples the '\' means the example should be all on one
  477. line.
  478. Display the contents of a certificate:
  479. openssl x509 -in cert.pem -noout -text
  480. Display the "Subject Alternative Name" extension of a certificate:
  481. openssl x509 -in cert.pem -noout -ext subjectAltName
  482. Display more extensions of a certificate:
  483. openssl x509 -in cert.pem -noout -ext subjectAltName,nsCertType
  484. Display the certificate serial number:
  485. openssl x509 -in cert.pem -noout -serial
  486. Display the certificate subject name:
  487. openssl x509 -in cert.pem -noout -subject
  488. Display the certificate subject name in RFC2253 form:
  489. openssl x509 -in cert.pem -noout -subject -nameopt RFC2253
  490. Display the certificate subject name in oneline form on a terminal
  491. supporting UTF8:
  492. openssl x509 -in cert.pem -noout -subject -nameopt oneline,-esc_msb
  493. Display the certificate SHA1 fingerprint:
  494. openssl x509 -sha1 -in cert.pem -noout -fingerprint
  495. Convert a certificate from PEM to DER format:
  496. openssl x509 -in cert.pem -inform PEM -out cert.der -outform DER
  497. Convert a certificate to a certificate request:
  498. openssl x509 -x509toreq -in cert.pem -out req.pem -signkey key.pem
  499. Convert a certificate request into a self signed certificate using
  500. extensions for a CA:
  501. openssl x509 -req -in careq.pem -extfile openssl.cnf -extensions v3_ca \
  502. -signkey key.pem -out cacert.pem
  503. Sign a certificate request using the CA certificate above and add user
  504. certificate extensions:
  505. openssl x509 -req -in req.pem -extfile openssl.cnf -extensions v3_usr \
  506. -CA cacert.pem -CAkey key.pem -CAcreateserial
  507. Set a certificate to be trusted for SSL client use and change set its alias to
  508. "Steve's Class 1 CA"
  509. openssl x509 -in cert.pem -addtrust clientAuth \
  510. -setalias "Steve's Class 1 CA" -out trust.pem
  511. =head1 NOTES
  512. The conversion to UTF8 format used with the name options assumes that
  513. T61Strings use the ISO8859-1 character set. This is wrong but Netscape
  514. and MSIE do this as do many certificates. So although this is incorrect
  515. it is more likely to display the majority of certificates correctly.
  516. The B<-email> option searches the subject name and the subject alternative
  517. name extension. Only unique email addresses will be printed out: it will
  518. not print the same address more than once.
  519. =head1 CERTIFICATE EXTENSIONS
  520. The B<-purpose> option checks the certificate extensions and determines
  521. what the certificate can be used for. The actual checks done are rather
  522. complex and include various hacks and workarounds to handle broken
  523. certificates and software.
  524. The same code is used when verifying untrusted certificates in chains
  525. so this section is useful if a chain is rejected by the verify code.
  526. The basicConstraints extension CA flag is used to determine whether the
  527. certificate can be used as a CA. If the CA flag is true then it is a CA,
  528. if the CA flag is false then it is not a CA. B<All> CAs should have the
  529. CA flag set to true.
  530. If the basicConstraints extension is absent then the certificate is
  531. considered to be a "possible CA" other extensions are checked according
  532. to the intended use of the certificate. A warning is given in this case
  533. because the certificate should really not be regarded as a CA: however
  534. it is allowed to be a CA to work around some broken software.
  535. If the certificate is a V1 certificate (and thus has no extensions) and
  536. it is self signed it is also assumed to be a CA but a warning is again
  537. given: this is to work around the problem of Verisign roots which are V1
  538. self signed certificates.
  539. If the keyUsage extension is present then additional restraints are
  540. made on the uses of the certificate. A CA certificate B<must> have the
  541. keyCertSign bit set if the keyUsage extension is present.
  542. The extended key usage extension places additional restrictions on the
  543. certificate uses. If this extension is present (whether critical or not)
  544. the key can only be used for the purposes specified.
  545. A complete description of each test is given below. The comments about
  546. basicConstraints and keyUsage and V1 certificates above apply to B<all>
  547. CA certificates.
  548. =over 4
  549. =item B<SSL Client>
  550. The extended key usage extension must be absent or include the "web client
  551. authentication" OID. keyUsage must be absent or it must have the
  552. digitalSignature bit set. Netscape certificate type must be absent or it must
  553. have the SSL client bit set.
  554. =item B<SSL Client CA>
  555. The extended key usage extension must be absent or include the "web client
  556. authentication" OID. Netscape certificate type must be absent or it must have
  557. the SSL CA bit set: this is used as a work around if the basicConstraints
  558. extension is absent.
  559. =item B<SSL Server>
  560. The extended key usage extension must be absent or include the "web server
  561. authentication" and/or one of the SGC OIDs. keyUsage must be absent or it
  562. must have the digitalSignature, the keyEncipherment set or both bits set.
  563. Netscape certificate type must be absent or have the SSL server bit set.
  564. =item B<SSL Server CA>
  565. The extended key usage extension must be absent or include the "web server
  566. authentication" and/or one of the SGC OIDs. Netscape certificate type must
  567. be absent or the SSL CA bit must be set: this is used as a work around if the
  568. basicConstraints extension is absent.
  569. =item B<Netscape SSL Server>
  570. For Netscape SSL clients to connect to an SSL server it must have the
  571. keyEncipherment bit set if the keyUsage extension is present. This isn't
  572. always valid because some cipher suites use the key for digital signing.
  573. Otherwise it is the same as a normal SSL server.
  574. =item B<Common S/MIME Client Tests>
  575. The extended key usage extension must be absent or include the "email
  576. protection" OID. Netscape certificate type must be absent or should have the
  577. S/MIME bit set. If the S/MIME bit is not set in Netscape certificate type
  578. then the SSL client bit is tolerated as an alternative but a warning is shown:
  579. this is because some Verisign certificates don't set the S/MIME bit.
  580. =item B<S/MIME Signing>
  581. In addition to the common S/MIME client tests the digitalSignature bit or
  582. the nonRepudiation bit must be set if the keyUsage extension is present.
  583. =item B<S/MIME Encryption>
  584. In addition to the common S/MIME tests the keyEncipherment bit must be set
  585. if the keyUsage extension is present.
  586. =item B<S/MIME CA>
  587. The extended key usage extension must be absent or include the "email
  588. protection" OID. Netscape certificate type must be absent or must have the
  589. S/MIME CA bit set: this is used as a work around if the basicConstraints
  590. extension is absent.
  591. =item B<CRL Signing>
  592. The keyUsage extension must be absent or it must have the CRL signing bit
  593. set.
  594. =item B<CRL Signing CA>
  595. The normal CA tests apply. Except in this case the basicConstraints extension
  596. must be present.
  597. =back
  598. =head1 BUGS
  599. Extensions in certificates are not transferred to certificate requests and
  600. vice versa.
  601. It is possible to produce invalid certificates or requests by specifying the
  602. wrong private key or using inconsistent options in some cases: these should
  603. be checked.
  604. There should be options to explicitly set such things as start and end
  605. dates rather than an offset from the current time.
  606. =head1 SEE ALSO
  607. L<openssl(1)>,
  608. L<openssl-req(1)>,
  609. L<openssl-ca(1)>,
  610. L<openssl-genrsa(1)>,
  611. L<openssl-gendsa(1)>,
  612. L<openssl-verify(1)>,
  613. L<x509v3_config(5)>
  614. =head1 HISTORY
  615. The hash algorithm used in the B<-subject_hash> and B<-issuer_hash> options
  616. before OpenSSL 1.0.0 was based on the deprecated MD5 algorithm and the encoding
  617. of the distinguished name. In OpenSSL 1.0.0 and later it is based on a canonical
  618. version of the DN using SHA1. This means that any directories using the old
  619. form must have their links rebuilt using L<openssl-rehash(1)> or similar.
  620. =head1 COPYRIGHT
  621. Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved.
  622. Licensed under the Apache License 2.0 (the "License"). You may not use
  623. this file except in compliance with the License. You can obtain a copy
  624. in the file LICENSE in the source distribution or at
  625. L<https://www.openssl.org/source/license.html>.
  626. =cut