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