openssl-pkey.html 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <?xml version="1.0" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <title>openssl-pkey</title>
  6. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  7. <link rev="made" href="mailto:root@localhost" />
  8. </head>
  9. <body>
  10. <ul id="index">
  11. <li><a href="#NAME">NAME</a></li>
  12. <li><a href="#SYNOPSIS">SYNOPSIS</a></li>
  13. <li><a href="#DESCRIPTION">DESCRIPTION</a></li>
  14. <li><a href="#OPTIONS">OPTIONS</a>
  15. <ul>
  16. <li><a href="#General-options">General options</a></li>
  17. <li><a href="#Input-options">Input options</a></li>
  18. <li><a href="#Output-options">Output options</a></li>
  19. </ul>
  20. </li>
  21. <li><a href="#EXAMPLES">EXAMPLES</a></li>
  22. <li><a href="#SEE-ALSO">SEE ALSO</a></li>
  23. <li><a href="#HISTORY">HISTORY</a></li>
  24. <li><a href="#COPYRIGHT">COPYRIGHT</a></li>
  25. </ul>
  26. <h1 id="NAME">NAME</h1>
  27. <p>openssl-pkey - public or private key processing command</p>
  28. <h1 id="SYNOPSIS">SYNOPSIS</h1>
  29. <p><b>openssl</b> <b>pkey</b> [<b>-help</b>] [<b>-engine</b> <i>id</i>] [<b>-provider</b> <i>name</i>] [<b>-provider-path</b> <i>path</i>] [<b>-propquery</b> <i>propq</i>] [<b>-check</b>] [<b>-pubcheck</b>] [<b>-in</b> <i>filename</i>|<i>uri</i>] [<b>-inform</b> <b>DER</b>|<b>PEM</b>|<b>P12</b>|<b>ENGINE</b>] [<b>-passin</b> <i>arg</i>] [<b>-pubin</b>] [<b>-out</b> <i>filename</i>] [<b>-outform</b> <b>DER</b>|<b>PEM</b>] [<b>-<i>cipher</i></b>] [<b>-passout</b> <i>arg</i>] [<b>-traditional</b>] [<b>-pubout</b>] [<b>-noout</b>] [<b>-text</b>] [<b>-text_pub</b>] [<b>-ec_conv_form</b> <i>arg</i>] [<b>-ec_param_enc</b> <i>arg</i>]</p>
  30. <h1 id="DESCRIPTION">DESCRIPTION</h1>
  31. <p>This command processes public or private keys. They can be converted between various forms and their components printed.</p>
  32. <h1 id="OPTIONS">OPTIONS</h1>
  33. <h2 id="General-options">General options</h2>
  34. <dl>
  35. <dt id="help"><b>-help</b></dt>
  36. <dd>
  37. <p>Print out a usage message.</p>
  38. </dd>
  39. <dt id="engine-id"><b>-engine</b> <i>id</i></dt>
  40. <dd>
  41. <p>See <a href="../man1/openssl.html">&quot;Engine Options&quot; in openssl(1)</a>. This option is deprecated.</p>
  42. </dd>
  43. <dt id="provider-name"><b>-provider</b> <i>name</i></dt>
  44. <dd>
  45. </dd>
  46. <dt id="provider-path-path"><b>-provider-path</b> <i>path</i></dt>
  47. <dd>
  48. </dd>
  49. <dt id="propquery-propq"><b>-propquery</b> <i>propq</i></dt>
  50. <dd>
  51. <p>See <a href="../man1/openssl.html">&quot;Provider Options&quot; in openssl(1)</a>, <a href="../man7/provider.html">provider(7)</a>, and <a href="../man7/property.html">property(7)</a>.</p>
  52. </dd>
  53. <dt id="check"><b>-check</b></dt>
  54. <dd>
  55. <p>This option checks the consistency of a key pair for both public and private components.</p>
  56. </dd>
  57. <dt id="pubcheck"><b>-pubcheck</b></dt>
  58. <dd>
  59. <p>This option checks the correctness of either a public key or the public component of a key pair.</p>
  60. </dd>
  61. </dl>
  62. <h2 id="Input-options">Input options</h2>
  63. <dl>
  64. <dt id="in-filename-uri"><b>-in</b> <i>filename</i>|<i>uri</i></dt>
  65. <dd>
  66. <p>This specifies the input to read a key from or standard input if this option is not specified. If the key input is encrypted and <b>-passin</b> is not given a pass phrase will be prompted for.</p>
  67. </dd>
  68. <dt id="inform-DER-PEM-P12-ENGINE"><b>-inform</b> <b>DER</b>|<b>PEM</b>|<b>P12</b>|<b>ENGINE</b></dt>
  69. <dd>
  70. <p>The key input format; unspecified by default. See <a href="../man1/openssl-format-options.html">openssl-format-options(1)</a> for details.</p>
  71. </dd>
  72. <dt id="passin-arg"><b>-passin</b> <i>arg</i></dt>
  73. <dd>
  74. <p>The password source for the key input.</p>
  75. <p>For more information about the format of <b>arg</b> see <a href="../man1/openssl-passphrase-options.html">openssl-passphrase-options(1)</a>.</p>
  76. </dd>
  77. <dt id="pubin"><b>-pubin</b></dt>
  78. <dd>
  79. <p>By default a private key is read from the input. With this option a public key is read instead. If the input contains no public key but a private key, its public part is used.</p>
  80. </dd>
  81. </dl>
  82. <h2 id="Output-options">Output options</h2>
  83. <dl>
  84. <dt id="out-filename"><b>-out</b> <i>filename</i></dt>
  85. <dd>
  86. <p>This specifies the output filename to save the encoded and/or text output of key or standard output if this option is not specified. If any cipher option is set but no <b>-passout</b> is given then a pass phrase will be prompted for. The output filename should <b>not</b> be the same as the input filename.</p>
  87. </dd>
  88. <dt id="outform-DER-PEM"><b>-outform</b> <b>DER</b>|<b>PEM</b></dt>
  89. <dd>
  90. <p>The key output format; the default is <b>PEM</b>. See <a href="../man1/openssl-format-options.html">openssl-format-options(1)</a> for details.</p>
  91. </dd>
  92. <dt id="cipher"><b>-<i>cipher</i></b></dt>
  93. <dd>
  94. <p>Encrypt the PEM encoded private key with the supplied cipher. Any algorithm name accepted by EVP_get_cipherbyname() is acceptable such as <b>aes128</b>. Encryption is not supported for DER output.</p>
  95. </dd>
  96. <dt id="passout-arg"><b>-passout</b> <i>arg</i></dt>
  97. <dd>
  98. <p>The password source for the output file.</p>
  99. <p>For more information about the format of <b>arg</b> see <a href="../man1/openssl-passphrase-options.html">openssl-passphrase-options(1)</a>.</p>
  100. </dd>
  101. <dt id="traditional"><b>-traditional</b></dt>
  102. <dd>
  103. <p>Normally a private key is written using standard format: this is PKCS#8 form with the appropriate encryption algorithm (if any). If the <b>-traditional</b> option is specified then the older &quot;traditional&quot; format is used instead.</p>
  104. </dd>
  105. <dt id="pubout"><b>-pubout</b></dt>
  106. <dd>
  107. <p>By default the private and public key is output; this option restricts the output to the public components. This option is automatically set if the input is a public key.</p>
  108. <p>When combined with <b>-text</b>, this is equivalent to <b>-text_pub</b>.</p>
  109. </dd>
  110. <dt id="noout"><b>-noout</b></dt>
  111. <dd>
  112. <p>Do not output the key in encoded form.</p>
  113. </dd>
  114. <dt id="text"><b>-text</b></dt>
  115. <dd>
  116. <p>Output the various key components in plain text (possibly in addition to the PEM encoded form). This cannot be combined with encoded output in DER format.</p>
  117. </dd>
  118. <dt id="text_pub"><b>-text_pub</b></dt>
  119. <dd>
  120. <p>Output in text form only the public key components (also for private keys). This cannot be combined with encoded output in DER format.</p>
  121. </dd>
  122. <dt id="ec_conv_form-arg"><b>-ec_conv_form</b> <i>arg</i></dt>
  123. <dd>
  124. <p>This option only applies to elliptic-curve based keys.</p>
  125. <p>This specifies how the points on the elliptic curve are converted into octet strings. Possible values are: <b>compressed</b> (the default value), <b>uncompressed</b> and <b>hybrid</b>. For more information regarding the point conversion forms please read the X9.62 standard. <b>Note</b> Due to patent issues the <b>compressed</b> option is disabled by default for binary curves and can be enabled by defining the preprocessor macro <b>OPENSSL_EC_BIN_PT_COMP</b> at compile time.</p>
  126. </dd>
  127. <dt id="ec_param_enc-arg"><b>-ec_param_enc</b> <i>arg</i></dt>
  128. <dd>
  129. <p>This option only applies to elliptic curve based public and private keys.</p>
  130. <p>This specifies how the elliptic curve parameters are encoded. Possible value are: <b>named_curve</b>, i.e. the ec parameters are specified by an OID, or <b>explicit</b> where the ec parameters are explicitly given (see RFC 3279 for the definition of the EC parameters structures). The default value is <b>named_curve</b>. <b>Note</b> the <b>implicitlyCA</b> alternative, as specified in RFC 3279, is currently not implemented in OpenSSL.</p>
  131. </dd>
  132. </dl>
  133. <h1 id="EXAMPLES">EXAMPLES</h1>
  134. <p>To remove the pass phrase on a private key:</p>
  135. <pre><code>openssl pkey -in key.pem -out keyout.pem</code></pre>
  136. <p>To encrypt a private key using triple DES:</p>
  137. <pre><code>openssl pkey -in key.pem -des3 -out keyout.pem</code></pre>
  138. <p>To convert a private key from PEM to DER format:</p>
  139. <pre><code>openssl pkey -in key.pem -outform DER -out keyout.der</code></pre>
  140. <p>To print out the components of a private key to standard output:</p>
  141. <pre><code>openssl pkey -in key.pem -text -noout</code></pre>
  142. <p>To print out the public components of a private key to standard output:</p>
  143. <pre><code>openssl pkey -in key.pem -text_pub -noout</code></pre>
  144. <p>To just output the public part of a private key:</p>
  145. <pre><code>openssl pkey -in key.pem -pubout -out pubkey.pem</code></pre>
  146. <p>To change the EC parameters encoding to <b>explicit</b>:</p>
  147. <pre><code>openssl pkey -in key.pem -ec_param_enc explicit -out keyout.pem</code></pre>
  148. <p>To change the EC point conversion form to <b>compressed</b>:</p>
  149. <pre><code>openssl pkey -in key.pem -ec_conv_form compressed -out keyout.pem</code></pre>
  150. <h1 id="SEE-ALSO">SEE ALSO</h1>
  151. <p><a href="../man1/openssl.html">openssl(1)</a>, <a href="../man1/openssl-genpkey.html">openssl-genpkey(1)</a>, <a href="../man1/openssl-rsa.html">openssl-rsa(1)</a>, <a href="../man1/openssl-pkcs8.html">openssl-pkcs8(1)</a>, <a href="../man1/openssl-dsa.html">openssl-dsa(1)</a>, <a href="../man1/openssl-genrsa.html">openssl-genrsa(1)</a>, <a href="../man1/openssl-gendsa.html">openssl-gendsa(1)</a></p>
  152. <h1 id="HISTORY">HISTORY</h1>
  153. <p>The <b>-engine</b> option was deprecated in OpenSSL 3.0.</p>
  154. <h1 id="COPYRIGHT">COPYRIGHT</h1>
  155. <p>Copyright 2006-2023 The OpenSSL Project Authors. All Rights Reserved.</p>
  156. <p>Licensed under the Apache License 2.0 (the &quot;License&quot;). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <a href="https://www.openssl.org/source/license.html">https://www.openssl.org/source/license.html</a>.</p>
  157. </body>
  158. </html>