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>]
35 =for openssl ifdef engine
39 This command processes public or private keys. They can be
40 converted between various forms and their components printed.
44 =head2 General options
50 Print out a usage message.
52 {- $OpenSSL::safe::opt_engine_item -}
54 {- $OpenSSL::safe::opt_provider_item -}
58 This option checks the consistency of a key pair for both public and private
63 This option checks the correctness of either a public key
64 or the public component of a key pair.
72 =item B<-in> I<filename>|I<uri>
74 This specifies the input to read a key from
75 or standard input if this option is not specified.
76 If the key input is encrypted and B<-passin> is not given
77 a pass phrase will be prompted for.
79 =item B<-inform> B<DER>|B<PEM>|B<P12>|B<ENGINE>
81 The key input format; unspecified by default.
82 See L<openssl-format-options(1)> for details.
84 =item B<-passin> I<arg>
86 The password source for the key input.
88 For more information about the format of B<arg>
89 see L<openssl-passphrase-options(1)>.
93 By default a private key is read from the input.
94 With this option only the public components are read.
102 =item B<-out> I<filename>
104 This specifies the output filename to save the encoded and/or text output of key
105 or standard output if this option is not specified.
106 If any cipher option is set but no B<-passout> is given
107 then a pass phrase will be prompted for.
108 The output filename should B<not> be the same as the input filename.
110 =item B<-outform> B<DER>|B<PEM>
112 The key output format; the default is B<PEM>.
113 See L<openssl-format-options(1)> for details.
117 Encrypt the PEM encoded private key with the supplied cipher. Any algorithm
118 name accepted by EVP_get_cipherbyname() is acceptable such as B<aes128>.
119 Encryption is not supported for DER output.
121 =item B<-passout> I<arg>
123 The password source for the output file.
125 For more information about the format of B<arg>
126 see L<openssl-passphrase-options(1)>.
128 =item B<-traditional>
130 Normally a private key is written using standard format: this is PKCS#8 form
131 with the appropriate encryption algorithm (if any). If the B<-traditional>
132 option is specified then the older "traditional" format is used instead.
136 By default the encoded private and public key is output;
137 this option restricts the encoded output to the public components.
138 This option is automatically set if the input is a public key.
142 Do not output the key in encoded form.
146 Output the various key components in plain text
147 (possibly in addition to the PEM encoded form).
148 This cannot be combined with encoded output in DER format.
152 Output in text form only the public key components (also for private keys).
153 This cannot be combined with encoded output in DER format.
155 =item B<-ec_conv_form> I<arg>
157 This option only applies to elliptic-curve based keys.
159 This specifies how the points on the elliptic curve are converted
160 into octet strings. Possible values are: B<compressed> (the default
161 value), B<uncompressed> and B<hybrid>. For more information regarding
162 the point conversion forms please read the X9.62 standard.
163 B<Note> Due to patent issues the B<compressed> option is disabled
164 by default for binary curves and can be enabled by defining
165 the preprocessor macro B<OPENSSL_EC_BIN_PT_COMP> at compile time.
167 =item B<-ec_param_enc> I<arg>
169 This option only applies to elliptic curve based public and private keys.
171 This specifies how the elliptic curve parameters are encoded.
172 Possible value are: B<named_curve>, i.e. the ec parameters are
173 specified by an OID, or B<explicit> where the ec parameters are
174 explicitly given (see RFC 3279 for the definition of the
175 EC parameters structures). The default value is B<named_curve>.
176 B<Note> the B<implicitlyCA> alternative, as specified in RFC 3279,
177 is currently not implemented in OpenSSL.
183 To remove the pass phrase on a private key:
185 openssl pkey -in key.pem -out keyout.pem
187 To encrypt a private key using triple DES:
189 openssl pkey -in key.pem -des3 -out keyout.pem
191 To convert a private key from PEM to DER format:
193 openssl pkey -in key.pem -outform DER -out keyout.der
195 To print out the components of a private key to standard output:
197 openssl pkey -in key.pem -text -noout
199 To print out the public components of a private key to standard output:
201 openssl pkey -in key.pem -text_pub -noout
203 To just output the public part of a private key:
205 openssl pkey -in key.pem -pubout -out pubkey.pem
207 To change the EC parameters encoding to B<explicit>:
209 openssl pkey -in key.pem -ec_param_enc explicit -out keyout.pem
211 To change the EC point conversion form to B<compressed>:
213 openssl pkey -in key.pem -ec_conv_form compressed -out keyout.pem
218 L<openssl-genpkey(1)>,
222 L<openssl-genrsa(1)>,
227 The B<-engine> option was deprecated in OpenSSL 3.0.
231 Copyright 2006-2021 The OpenSSL Project Authors. All Rights Reserved.
233 Licensed under the Apache License 2.0 (the "License"). You may not use
234 this file except in compliance with the License. You can obtain a copy
235 in the file LICENSE in the source distribution or at
236 L<https://www.openssl.org/source/license.html>.