1PKEY(1) OpenSSL PKEY(1)
2
3
4
6 openssl-pkey, pkey - public or private key processing tool
7
9 openssl pkey [-help] [-inform PEM|DER] [-outform PEM|DER] [-in
10 filename] [-passin arg] [-out filename] [-passout arg] [-traditional]
11 [-cipher] [-text] [-text_pub] [-noout] [-pubin] [-pubout] [-engine id]
12 [-check] [-pubcheck]
13
15 The pkey command processes public or private keys. They can be
16 converted between various forms and their components printed out.
17
19 -help
20 Print out a usage message.
21
22 -inform DER|PEM
23 This specifies the input format DER or PEM. The default format is
24 PEM.
25
26 -outform DER|PEM
27 This specifies the output format, the options have the same meaning
28 and default as the -inform option.
29
30 -in filename
31 This specifies the input filename to read a key from or standard
32 input if this option is not specified. If the key is encrypted a
33 pass phrase will be prompted for.
34
35 -passin arg
36 The input file password source. For more information about the
37 format of arg see "Pass Phrase Options" in openssl(1).
38
39 -out filename
40 This specifies the output filename to write a key to or standard
41 output if this option is not specified. If any encryption options
42 are set then a pass phrase will be prompted for. The output
43 filename should not be the same as the input filename.
44
45 -passout password
46 The output file password source. For more information about the
47 format of arg see "Pass Phrase Options" in openssl(1).
48
49 -traditional
50 Normally a private key is written using standard format: this is
51 PKCS#8 form with the appropriate encryption algorithm (if any). If
52 the -traditional option is specified then the older "traditional"
53 format is used instead.
54
55 -cipher
56 These options encrypt the private key with the supplied cipher. Any
57 algorithm name accepted by EVP_get_cipherbyname() is acceptable
58 such as des3.
59
60 -text
61 Prints out the various public or private key components in plain
62 text in addition to the encoded version.
63
64 -text_pub
65 Print out only public key components even if a private key is being
66 processed.
67
68 -noout
69 Do not output the encoded version of the key.
70
71 -pubin
72 By default a private key is read from the input file: with this
73 option a public key is read instead.
74
75 -pubout
76 By default a private key is output: with this option a public key
77 will be output instead. This option is automatically set if the
78 input is a public key.
79
80 -engine id
81 Specifying an engine (by its unique id string) will cause pkey to
82 attempt to obtain a functional reference to the specified engine,
83 thus initialising it if needed. The engine will then be set as the
84 default for all available algorithms.
85
86 -check
87 This option checks the consistency of a key pair for both public
88 and private components.
89
90 -pubcheck
91 This option checks the correctness of either a public key or the
92 public component of a key pair.
93
95 To remove the pass phrase on an RSA private key:
96
97 openssl pkey -in key.pem -out keyout.pem
98
99 To encrypt a private key using triple DES:
100
101 openssl pkey -in key.pem -des3 -out keyout.pem
102
103 To convert a private key from PEM to DER format:
104
105 openssl pkey -in key.pem -outform DER -out keyout.der
106
107 To print out the components of a private key to standard output:
108
109 openssl pkey -in key.pem -text -noout
110
111 To print out the public components of a private key to standard output:
112
113 openssl pkey -in key.pem -text_pub -noout
114
115 To just output the public part of a private key:
116
117 openssl pkey -in key.pem -pubout -out pubkey.pem
118
120 genpkey(1), rsa(1), pkcs8(1), dsa(1), genrsa(1), gendsa(1)
121
123 Copyright 2006-2021 The OpenSSL Project Authors. All Rights Reserved.
124
125 Licensed under the OpenSSL license (the "License"). You may not use
126 this file except in compliance with the License. You can obtain a copy
127 in the file LICENSE in the source distribution or at
128 <https://www.openssl.org/source/license.html>.
129
130
131
1321.1.1l 2021-09-15 PKEY(1)