OPENSSL-PKEY(1ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’– 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" in openssl(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" in openssl(1), plus provider(7) and property(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 in openssl-format-options(1) πŸ“š
  • -passin arg β€” the password source for the key input. for the format of arg, go see openssl-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. see openssl-format-options(1) for the deets.
  • -cipher β€” encrypts the PEM encoded private key with the supplied cipher. any algorithm name that EVP_get_cipherbyname() accepts is fine, like aes128. 🚨 but encryption is not supported for DER output, periodt.
  • -passout arg β€” the password source for the output file. for the format of arg, see openssl-passphrase-options(1).
  • -traditional β€” normally a private key is written in the standard format: PKCS#8 with the appropriate encryption algorithm (if any). specify -traditional and 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)
    • uncompressed
    • hybrid

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 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