OpenSSL RSA Key Utilities

From UNIX Systems Administration
Jump to navigation Jump to search

RSA Keys PEM-formatted

RSA PEM-formatted Key Information

  • Extension(s) .key, .pem
  • PEM encoded RSA private key is a format that stores an RSA private key, for use with cryptographic systems such as SSL.
  • A key file is plain text, with base64-encoded payload data. It contains a line that reads "-----BEGIN RSA PRIVATE KEY-----".

RSA PEM-formatted Key Commands

  1. View the contents of a key file.
    1. # openssl rsa -noout -text -in <hostname>.key
  2. Generate a new private key.
    1. # openssl genrsa -out <hostname>.key 2048
  3. Add a password to an existing private key.
    1. # openssl rsa -des3 -in <hostname-unprotected>.key -out <hostname-protected>.key
  4. Remove a password from an existing private key.
    1. # openssl rsa -in <hostname-protected>.key -out <hostname-unprotected>.key

RSA Keys DER-formatted

RSA DER-formateed Key Information

  • Extension(s) .key
  • DER encoded RSA private key is an RSA private key format that stores the same information as PEM encoded RSA private key, but encoded in DER format instead of PEM format.

RSA DER-formatted Key Information

  1. View the contents of a DER-formatted key.
    1. # openssl rsa -noout -text -inform der -in <hostname-der>.key
  2. Convert a DER-formatted key to a PEM-formatted key.
    1. # openssl rsa -inform der-in <hostname-der>.key -out <hostname-pem>.key

Further Reading

  1. PEM encoded RSA private key
  2. DER encoded RSA private key
  3. OpenSSL RSA