| 1 |
.\" -*- mode: troff; coding: utf-8 -*- |
| 2 |
.\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45) |
| 3 |
.\" |
| 4 |
.\" Standard preamble: |
| 5 |
.\" ======================================================================== |
| 6 |
.de Sp \" Vertical space (when we can't use .PP) |
| 7 |
.if t .sp .5v |
| 8 |
.if n .sp |
| 9 |
.. |
| 10 |
.de Vb \" Begin verbatim text |
| 11 |
.ft CW |
| 12 |
.nf |
| 13 |
.ne \\$1 |
| 14 |
.. |
| 15 |
.de Ve \" End verbatim text |
| 16 |
.ft R |
| 17 |
.fi |
| 18 |
.. |
| 19 |
.\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. |
| 20 |
.ie n \{\ |
| 21 |
. ds C` "" |
| 22 |
. ds C' "" |
| 23 |
'br\} |
| 24 |
.el\{\ |
| 25 |
. ds C` |
| 26 |
. ds C' |
| 27 |
'br\} |
| 28 |
.\" |
| 29 |
.\" Escape single quotes in literal strings from groff's Unicode transform. |
| 30 |
.ie \n(.g .ds Aq \(aq |
| 31 |
.el .ds Aq ' |
| 32 |
.\" |
| 33 |
.\" If the F register is >0, we'll generate index entries on stderr for |
| 34 |
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index |
| 35 |
.\" entries marked with X<> in POD. Of course, you'll have to process the |
| 36 |
.\" output yourself in some meaningful fashion. |
| 37 |
.\" |
| 38 |
.\" Avoid warning from groff about undefined register 'F'. |
| 39 |
.de IX |
| 40 |
.. |
| 41 |
.nr rF 0 |
| 42 |
.if \n(.g .if rF .nr rF 1 |
| 43 |
.if (\n(rF:(\n(.g==0)) \{\ |
| 44 |
. if \nF \{\ |
| 45 |
. de IX |
| 46 |
. tm Index:\\$1\t\\n%\t"\\$2" |
| 47 |
.. |
| 48 |
. if !\nF==2 \{\ |
| 49 |
. nr % 0 |
| 50 |
. nr F 2 |
| 51 |
. \} |
| 52 |
. \} |
| 53 |
.\} |
| 54 |
.rr rF |
| 55 |
.\" ======================================================================== |
| 56 |
.\" |
| 57 |
.IX Title "OPENSSL-PKEY 1SSL" |
| 58 |
.TH OPENSSL-PKEY 1SSL 2026-04-07 3.6.2 OpenSSL |
| 59 |
.\" For nroff, turn off justification. Always turn off hyphenation; it makes |
| 60 |
.\" way too many mistakes in technical documents. |
| 61 |
.if n .ad l |
| 62 |
.nh |
| 63 |
.SH NAME |
| 64 |
openssl\-pkey \- public or private key processing command |
| 65 |
.SH SYNOPSIS |
| 66 |
.IX Header "SYNOPSIS" |
| 67 |
\&\fBopenssl\fR \fBpkey\fR |
| 68 |
[\fB\-help\fR] |
| 69 |
[\fB\-engine\fR \fIid\fR] |
| 70 |
[\fB\-provider\fR \fIname\fR] |
| 71 |
[\fB\-provider\-path\fR \fIpath\fR] |
| 72 |
[\fB\-provparam\fR \fI[name:]key=value\fR] |
| 73 |
[\fB\-propquery\fR \fIpropq\fR] |
| 74 |
[\fB\-check\fR] |
| 75 |
[\fB\-pubcheck\fR] |
| 76 |
[\fB\-in\fR \fIfilename\fR|\fIuri\fR] |
| 77 |
[\fB\-inform\fR \fBDER\fR|\fBPEM\fR|\fBP12\fR|\fBENGINE\fR] |
| 78 |
[\fB\-passin\fR \fIarg\fR] |
| 79 |
[\fB\-pubin\fR] |
| 80 |
[\fB\-out\fR \fIfilename\fR] |
| 81 |
[\fB\-outform\fR \fBDER\fR|\fBPEM\fR] |
| 82 |
[\fB\-\fR\f(BIcipher\fR] |
| 83 |
[\fB\-passout\fR \fIarg\fR] |
| 84 |
[\fB\-traditional\fR] |
| 85 |
[\fB\-pubout\fR] |
| 86 |
[\fB\-noout\fR] |
| 87 |
[\fB\-text\fR] |
| 88 |
[\fB\-text_pub\fR] |
| 89 |
[\fB\-ec_conv_form\fR \fIarg\fR] |
| 90 |
[\fB\-ec_param_enc\fR \fIarg\fR] |
| 91 |
.SH DESCRIPTION |
| 92 |
.IX Header "DESCRIPTION" |
| 93 |
This command processes public or private keys. They can be |
| 94 |
converted between various forms and their components printed. |
| 95 |
.SH OPTIONS |
| 96 |
.IX Header "OPTIONS" |
| 97 |
.SS "General options" |
| 98 |
.IX Subsection "General options" |
| 99 |
.IP \fB\-help\fR 4 |
| 100 |
.IX Item "-help" |
| 101 |
Print out a usage message. |
| 102 |
.IP "\fB\-engine\fR \fIid\fR" 4 |
| 103 |
.IX Item "-engine id" |
| 104 |
See "Engine Options" in \fBopenssl\fR\|(1). |
| 105 |
This option is deprecated. |
| 106 |
.IP "\fB\-provider\fR \fIname\fR" 4 |
| 107 |
.IX Item "-provider name" |
| 108 |
.PD 0 |
| 109 |
.IP "\fB\-provider\-path\fR \fIpath\fR" 4 |
| 110 |
.IX Item "-provider-path path" |
| 111 |
.IP "\fB\-provparam\fR \fI[name:]key=value\fR" 4 |
| 112 |
.IX Item "-provparam [name:]key=value" |
| 113 |
.IP "\fB\-propquery\fR \fIpropq\fR" 4 |
| 114 |
.IX Item "-propquery propq" |
| 115 |
.PD |
| 116 |
See "Provider Options" in \fBopenssl\fR\|(1), \fBprovider\fR\|(7), and \fBproperty\fR\|(7). |
| 117 |
.IP \fB\-check\fR 4 |
| 118 |
.IX Item "-check" |
| 119 |
This option checks the consistency of a key pair for both public and private |
| 120 |
components. |
| 121 |
.IP \fB\-pubcheck\fR 4 |
| 122 |
.IX Item "-pubcheck" |
| 123 |
This option checks the correctness of either a public key |
| 124 |
or the public component of a key pair. |
| 125 |
.SS "Input options" |
| 126 |
.IX Subsection "Input options" |
| 127 |
.IP "\fB\-in\fR \fIfilename\fR|\fIuri\fR" 4 |
| 128 |
.IX Item "-in filename|uri" |
| 129 |
This specifies the input file to read a key from |
| 130 |
or standard input if this option is not specified. |
| 131 |
.Sp |
| 132 |
If the key input is encrypted and \fB\-passin\fR is not given |
| 133 |
a pass phrase will be prompted for. |
| 134 |
.IP "\fB\-inform\fR \fBDER\fR|\fBPEM\fR|\fBP12\fR|\fBENGINE\fR" 4 |
| 135 |
.IX Item "-inform DER|PEM|P12|ENGINE" |
| 136 |
The key input format; unspecified by default. |
| 137 |
See \fBopenssl\-format\-options\fR\|(1) for details. |
| 138 |
.IP "\fB\-passin\fR \fIarg\fR" 4 |
| 139 |
.IX Item "-passin arg" |
| 140 |
The password source for the key input. |
| 141 |
.Sp |
| 142 |
For more information about the format of \fBarg\fR |
| 143 |
see \fBopenssl\-passphrase\-options\fR\|(1). |
| 144 |
.IP \fB\-pubin\fR 4 |
| 145 |
.IX Item "-pubin" |
| 146 |
By default a private key is read from the input. |
| 147 |
With this option a public key is read instead. |
| 148 |
If the input contains no public key but a private key, its public part is used. |
| 149 |
.SS "Output options" |
| 150 |
.IX Subsection "Output options" |
| 151 |
.IP "\fB\-out\fR \fIfilename\fR" 4 |
| 152 |
.IX Item "-out filename" |
| 153 |
This specifies the output file to save the encoded and/or text output of key |
| 154 |
or standard output if this option is not specified. |
| 155 |
The output filename can be the same as the input filename, |
| 156 |
which leads to replacing the file contents. |
| 157 |
Note that file I/O is not atomic. The output file is truncated and then written. |
| 158 |
.Sp |
| 159 |
If any cipher option is set but no \fB\-passout\fR is given |
| 160 |
then a pass phrase will be prompted for. |
| 161 |
When password input is interrupted, the output file is not touched. |
| 162 |
.IP "\fB\-outform\fR \fBDER\fR|\fBPEM\fR" 4 |
| 163 |
.IX Item "-outform DER|PEM" |
| 164 |
The key output format; the default is \fBPEM\fR. |
| 165 |
See \fBopenssl\-format\-options\fR\|(1) for details. |
| 166 |
.IP \fB\-\fR\f(BIcipher\fR 4 |
| 167 |
.IX Item "-cipher" |
| 168 |
Encrypt the PEM encoded private key with the supplied cipher. Any algorithm |
| 169 |
name accepted by \fBEVP_get_cipherbyname()\fR is acceptable such as \fBaes128\fR. |
| 170 |
Encryption is not supported for DER output. |
| 171 |
.IP "\fB\-passout\fR \fIarg\fR" 4 |
| 172 |
.IX Item "-passout arg" |
| 173 |
The password source for the output file. |
| 174 |
.Sp |
| 175 |
For more information about the format of \fBarg\fR |
| 176 |
see \fBopenssl\-passphrase\-options\fR\|(1). |
| 177 |
.IP \fB\-traditional\fR 4 |
| 178 |
.IX Item "-traditional" |
| 179 |
Normally a private key is written using standard format: this is PKCS#8 form |
| 180 |
with the appropriate encryption algorithm (if any). If the \fB\-traditional\fR |
| 181 |
option is specified then the older "traditional" format is used instead. |
| 182 |
.IP \fB\-pubout\fR 4 |
| 183 |
.IX Item "-pubout" |
| 184 |
By default the private and public key is output; |
| 185 |
this option restricts the output to the public components. |
| 186 |
This option is automatically set if the input is a public key. |
| 187 |
.Sp |
| 188 |
When combined with \fB\-text\fR, this is equivalent to \fB\-text_pub\fR. |
| 189 |
.IP \fB\-noout\fR 4 |
| 190 |
.IX Item "-noout" |
| 191 |
Do not output the key in encoded form. |
| 192 |
.IP \fB\-text\fR 4 |
| 193 |
.IX Item "-text" |
| 194 |
Output the various key components in plain text |
| 195 |
(possibly in addition to the PEM encoded form). |
| 196 |
This cannot be combined with encoded output in DER format. |
| 197 |
.IP \fB\-text_pub\fR 4 |
| 198 |
.IX Item "-text_pub" |
| 199 |
Output in text form only the public key components (also for private keys). |
| 200 |
This cannot be combined with encoded output in DER format. |
| 201 |
.IP "\fB\-ec_conv_form\fR \fIarg\fR" 4 |
| 202 |
.IX Item "-ec_conv_form arg" |
| 203 |
This option only applies to elliptic-curve based keys. |
| 204 |
.Sp |
| 205 |
This specifies how the points on the elliptic curve are converted |
| 206 |
into octet strings. Possible values are: \fBcompressed\fR (the default |
| 207 |
value), \fBuncompressed\fR and \fBhybrid\fR. For more information regarding |
| 208 |
the point conversion forms please read the X9.62 standard. |
| 209 |
\&\fBNote\fR Due to patent issues the \fBcompressed\fR option is disabled |
| 210 |
by default for binary curves and can be enabled by defining |
| 211 |
the preprocessor macro \fBOPENSSL_EC_BIN_PT_COMP\fR at compile time. |
| 212 |
.IP "\fB\-ec_param_enc\fR \fIarg\fR" 4 |
| 213 |
.IX Item "-ec_param_enc arg" |
| 214 |
This option only applies to elliptic curve based public and private keys. |
| 215 |
.Sp |
| 216 |
This specifies how the elliptic curve parameters are encoded. |
| 217 |
Possible value are: \fBnamed_curve\fR, i.e. the ec parameters are |
| 218 |
specified by an OID, or \fBexplicit\fR where the ec parameters are |
| 219 |
explicitly given (see RFC 3279 for the definition of the |
| 220 |
EC parameters structures). The default value is \fBnamed_curve\fR. |
| 221 |
\&\fBNote\fR the \fBimplicitlyCA\fR alternative, as specified in RFC 3279, |
| 222 |
is currently not implemented in OpenSSL. |
| 223 |
.SH EXAMPLES |
| 224 |
.IX Header "EXAMPLES" |
| 225 |
To remove the pass phrase on a private key: |
| 226 |
.PP |
| 227 |
.Vb 1 |
| 228 |
\& openssl pkey \-in key.pem \-out keyout.pem |
| 229 |
.Ve |
| 230 |
.PP |
| 231 |
To encrypt a private key using triple DES: |
| 232 |
.PP |
| 233 |
.Vb 1 |
| 234 |
\& openssl pkey \-in key.pem \-des3 \-out keyout.pem |
| 235 |
.Ve |
| 236 |
.PP |
| 237 |
To convert a private key from PEM to DER format: |
| 238 |
.PP |
| 239 |
.Vb 1 |
| 240 |
\& openssl pkey \-in key.pem \-outform DER \-out keyout.der |
| 241 |
.Ve |
| 242 |
.PP |
| 243 |
To print out the components of a private key to standard output: |
| 244 |
.PP |
| 245 |
.Vb 1 |
| 246 |
\& openssl pkey \-in key.pem \-text \-noout |
| 247 |
.Ve |
| 248 |
.PP |
| 249 |
To print out the public components of a private key to standard output: |
| 250 |
.PP |
| 251 |
.Vb 1 |
| 252 |
\& openssl pkey \-in key.pem \-text_pub \-noout |
| 253 |
.Ve |
| 254 |
.PP |
| 255 |
To just output the public part of a private key: |
| 256 |
.PP |
| 257 |
.Vb 1 |
| 258 |
\& openssl pkey \-in key.pem \-pubout \-out pubkey.pem |
| 259 |
.Ve |
| 260 |
.PP |
| 261 |
To change the EC parameters encoding to \fBexplicit\fR: |
| 262 |
.PP |
| 263 |
.Vb 1 |
| 264 |
\& openssl pkey \-in key.pem \-ec_param_enc explicit \-out keyout.pem |
| 265 |
.Ve |
| 266 |
.PP |
| 267 |
To change the EC point conversion form to \fBcompressed\fR: |
| 268 |
.PP |
| 269 |
.Vb 1 |
| 270 |
\& openssl pkey \-in key.pem \-ec_conv_form compressed \-out keyout.pem |
| 271 |
.Ve |
| 272 |
.SH "SEE ALSO" |
| 273 |
.IX Header "SEE ALSO" |
| 274 |
\&\fBopenssl\fR\|(1), |
| 275 |
\&\fBopenssl\-genpkey\fR\|(1), |
| 276 |
\&\fBopenssl\-rsa\fR\|(1), |
| 277 |
\&\fBopenssl\-pkcs8\fR\|(1), |
| 278 |
\&\fBopenssl\-dsa\fR\|(1), |
| 279 |
\&\fBopenssl\-genrsa\fR\|(1), |
| 280 |
\&\fBopenssl\-gendsa\fR\|(1) |
| 281 |
.SH HISTORY |
| 282 |
.IX Header "HISTORY" |
| 283 |
The \fB\-engine\fR option was deprecated in OpenSSL 3.0. |
| 284 |
.SH COPYRIGHT |
| 285 |
.IX Header "COPYRIGHT" |
| 286 |
Copyright 2006\-2023 The OpenSSL Project Authors. All Rights Reserved. |
| 287 |
.PP |
| 288 |
Licensed under the Apache License 2.0 (the "License"). You may not use |
| 289 |
this file except in compliance with the License. You can obtain a copy |
| 290 |
in the file LICENSE in the source distribution or at |
| 291 |
<https://www.openssl.org/source/license.html>. |