OPENSSL-PKEY(1ossl)
π openssl-pkey(1ossl) π
okay so bestie, this is the openssl pkey page β the public or private key processing command from the OpenSSL fam. It's basically the glow-up station for your keys: convert them between forms, print their components, that whole vibe. β¨
πΈ SYNOPSIS πΈ
openssl pkey [-help] [-engine id] [-provider name] [-provider-path path]
[-provparam [name:]key=value] [-propquery propq] [-check] [-pubcheck]
[-in filename|uri] [-inform DER|PEM|P12|ENGINE] [-passin arg] [-pubin]
[-out filename] [-outform DER|PEM] [-cipher] [-passout arg]
[-traditional] [-pubout] [-noout] [-text] [-text_pub] [-ec_conv_form
arg] [-ec_param_enc arg]
π¦ DESCRIPTION π¦
So this command processes public or private keys β like, it's the main character of key handling. You can convert them between the various forms and print out their components. That's the whole gig. π
π OPTIONS π
β General options
-helpβ prints a usage message. classic, love that for us.-engine idβ see "Engine Options" inopenssl(1). ngl bestie, this option is deprecated π.-provider name,-provider-path path,-provparam [name:]key=value,-propquery propqβ all of these live in "Provider Options" inopenssl(1), plusprovider(7)andproperty(7). go read those, iykyk π«Ά-checkβ checks the consistency of a key pair, for both the public and private components. consistency check, slay.-pubcheckβ checks the correctness of either a public key or the public component of a key pair. just the public part getting its moment β¨
π Input options
-in filename|uriβ tells it which input file to read a key from. no option? then it reads from standard input, easy. and hey β if the key input is encrypted and you didn't give-passin, it'll prompt you for a pass phrase. no cap.-inform DER|PEM|P12|ENGINEβ the key input format. unspecified by default. details live inopenssl-format-options(1)π-passin argβ the password source for the key input. for the format of arg, go seeopenssl-passphrase-options(1).-pubinβ by default a private key is read from the input. with this option, a public key is read instead. and if the input has no public key but does have a private key, its public part is used. flexible king π
π§ Output options
-out filenameβ the output file where the encoded and/or text output of the key gets saved; if you don't specify it, standard output. β οΈ heads up: the output filename can be the same as the input filename, which literally replaces the file contents. and note, file I/O is not atomic β the output file gets truncated and then written. so yeah, be careful bestie π
Also: if any cipher option is set but no -passout is given, a pass phrase will be prompted for. and if the password input gets interrupted, the output file is not touched β small mercy π
-outform DER|PEMβ the key output format. default is PEM. seeopenssl-format-options(1)for the deets.-cipherβ encrypts the PEM encoded private key with the supplied cipher. any algorithm name thatEVP_get_cipherbyname()accepts is fine, likeaes128. π¨ but encryption is not supported for DER output, periodt.-passout argβ the password source for the output file. for the format of arg, seeopenssl-passphrase-options(1).-traditionalβ normally a private key is written in the standard format: PKCS#8 with the appropriate encryption algorithm (if any). specify-traditionaland you get the older "traditional" format instead. retro vibes π-puboutβ by default the private and public key are output; this restricts the output to just the public components. it's automatically set if the input is a public key, cute. and when you combine it with-text, it's equivalent to-text_pub. β¨-nooutβ doesn't output the key in encoded form. justβ¦ no out. simple as that.-textβ outputs the various key components in plain text (possibly in addition to the PEM encoded form). cannot be combined with encoded output in DER format, so don't even try π-text_pubβ outputs in text form only the public key components (also for private keys, yes really). also cannot be combined with encoded output in DER format. same rule, same energy.-ec_conv_form argβ this one only applies to elliptic-curve based keys π. it specifies how points on the elliptic curve get converted into octet strings. possible values:compressed(the default value)uncompressedhybrid
for more info on point conversion forms, read the X9.62 standard. π note: due to patent issues, the compressed option is disabled by default for binary curves and can be enabled by defining the preprocessor macro OPENSSL_EC_BIN_PT_COMP at compile time. patents, am i right π
-ec_param_enc argβ only applies to elliptic curve based public and private keys. specifies how the elliptic curve parameters are encoded. possible values:named_curveβ the ec parameters are specified by an OID (this is the default value)explicitβ the ec parameters are explicitly given (see RFC 3279 for the definition of the EC parameters structures)
note: the implicitlyCA alternative, as specified in RFC 3279, is currently not implemented in OpenSSL. so don't come for it, it's not there π
π EXAMPLES π
Wanna remove the pass phrase on a private key? say less:
openssl pkey -in key.pem -out keyout.pem
Encrypt a private key using triple DES:
openssl pkey -in key.pem -des3 -out keyout.pem
Convert a private key from PEM to DER format:
openssl pkey -in key.pem -outform DER -out keyout.der
Print out the components of a private key to standard output:
openssl pkey -in key.pem -text -noout
Print out the public components of a private key to standard output:
openssl pkey -in key.pem -text_pub -noout
Just output the public part of a private key:
openssl pkey -in key.pem -pubout -out pubkey.pem
Change the EC parameters encoding to explicit:
openssl pkey -in key.pem -ec_param_enc explicit -out keyout.pem
Change the EC point conversion form to compressed:
openssl pkey -in key.pem -ec_conv_form compressed -out keyout.pem
π SEE ALSO π
openssl(1), openssl-genpkey(1), openssl-rsa(1), openssl-pkcs8(1), openssl-dsa(1), openssl-genrsa(1), openssl-gendsa(1) β go read the whole friend group π
π HISTORY π
The -engine option was deprecated in OpenSSL 3.0. rip to a real one π«‘
π COPYRIGHT π
Copyright 2006-2023 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
and that's the page bestie π«Ά this whole thing is from OpenSSL 3.5.0, dated 2026-09-25, page OPENSSL-PKEY(1ossl) β iconic, no notes β¨ππ
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms