4 {- join("\n", @autowarntext) -}
10 openssl-pkey - public or private key processing command
16 {- $OpenSSL::safe::opt_engine_synopsis -}{- $OpenSSL::safe::opt_provider_synopsis -}
19 [B<-in> I<filename>|I<uri>]
20 [B<-inform> B<DER>|B<PEM>|B<P12>|B<ENGINE>]
24 [B<-outform> B<DER>|B<PEM>]
32 [B<-ec_conv_form> I<arg>]
33 [B<-ec_param_enc> I<arg>]
37 This command processes public or private keys. They can be
38 converted between various forms and their components printed.
42 =head2 General options
48 Print out a usage message.
50 {- $OpenSSL::safe::opt_engine_item -}
52 {- $OpenSSL::safe::opt_provider_item -}
56 This option checks the consistency of a key pair for both public and private
61 This option checks the correctness of either a public key
62 or the public component of a key pair.
70 =item B<-in> I<filename>|I<uri>
72 This specifies the input to read a key from
73 or standard input if this option is not specified.
74 If the key input is encrypted and B<-passin> is not given
75 a pass phrase will be prompted for.
77 =item B<-inform> B<DER>|B<PEM>|B<P12>|B<ENGINE>
79 The key input format; unspecified by default.
80 See L<openssl-format-options(1)> for details.
82 =item B<-passin> I<arg>
84 The password source for the key input.
86 For more information about the format of B<arg>
87 see L<openssl-passphrase-options(1)>.
91 By default a private key is read from the input.
92 With this option a public key is read instead.
93 If the input contains no public key but a private key, its public part is used.
101 =item B<-out> I<filename>
103 This specifies the output filename to save the encoded and/or text output of key
104 or standard output if this option is not specified.
105 If any cipher option is set but no B<-passout> is given
106 then a pass phrase will be prompted for.
107 The output filename should B<not> be the same as the input filename.
109 =item B<-outform> B<DER>|B<PEM>
111 The key output format; the default is B<PEM>.
112 See L<openssl-format-options(1)> for details.
116 Encrypt the PEM encoded private key with the supplied cipher. Any algorithm
117 name accepted by EVP_get_cipherbyname() is acceptable such as B<aes128>.
118 Encryption is not supported for DER output.
120 =item B<-passout> I<arg>
122 The password source for the output file.
124 For more information about the format of B<arg>
125 see L<openssl-passphrase-options(1)>.
127 =item B<-traditional>
129 Normally a private key is written using standard format: this is PKCS#8 form
130 with the appropriate encryption algorithm (if any). If the B<-traditional>
131 option is specified then the older "traditional" format is used instead.
135 By default the private and public key is output;
136 this option restricts the output to the public components.
137 This option is automatically set if the input is a public key.
139 When combined with B<-text>, this is equivalent to B<-text_pub>.
143 Do not output the key in encoded form.
147 Output the various key components in plain text
148 (possibly in addition to the PEM encoded form).
149 This cannot be combined with encoded output in DER format.
153 Output in text form only the public key components (also for private keys).
154 This cannot be combined with encoded output in DER format.
156 =item B<-ec_conv_form> I<arg>
158 This option only applies to elliptic-curve based keys.
160 This specifies how the points on the elliptic curve are converted
161 into octet strings. Possible values are: B<compressed> (the default
162 value), B<uncompressed> and B<hybrid>. For more information regarding
163 the point conversion forms please read the X9.62 standard.
164 B<Note> Due to patent issues the B<compressed> option is disabled
165 by default for binary curves and can be enabled by defining
166 the preprocessor macro B<OPENSSL_EC_BIN_PT_COMP> at compile time.
168 =item B<-ec_param_enc> I<arg>
170 This option only applies to elliptic curve based public and private keys.
172 This specifies how the elliptic curve parameters are encoded.
173 Possible value are: B<named_curve>, i.e. the ec parameters are
174 specified by an OID, or B<explicit> where the ec parameters are
175 explicitly given (see RFC 3279 for the definition of the
176 EC parameters structures). The default value is B<named_curve>.
177 B<Note> the B<implicitlyCA> alternative, as specified in RFC 3279,
178 is currently not implemented in OpenSSL.
184 To remove the pass phrase on a private key:
186 openssl pkey -in key.pem -out keyout.pem
188 To encrypt a private key using triple DES:
190 openssl pkey -in key.pem -des3 -out keyout.pem
192 To convert a private key from PEM to DER format:
194 openssl pkey -in key.pem -outform DER -out keyout.der
196 To print out the components of a private key to standard output:
198 openssl pkey -in key.pem -text -noout
200 To print out the public components of a private key to standard output:
202 openssl pkey -in key.pem -text_pub -noout
204 To just output the public part of a private key:
206 openssl pkey -in key.pem -pubout -out pubkey.pem
208 To change the EC parameters encoding to B<explicit>:
210 openssl pkey -in key.pem -ec_param_enc explicit -out keyout.pem
212 To change the EC point conversion form to B<compressed>:
214 openssl pkey -in key.pem -ec_conv_form compressed -out keyout.pem
219 L<openssl-genpkey(1)>,
223 L<openssl-genrsa(1)>,
228 The B<-engine> option was deprecated in OpenSSL 3.0.
232 Copyright 2006-2023 The OpenSSL Project Authors. All Rights Reserved.
234 Licensed under the Apache License 2.0 (the "License"). You may not use
235 this file except in compliance with the License. You can obtain a copy
236 in the file LICENSE in the source distribution or at
237 L<https://www.openssl.org/source/license.html>.