Is the key encrypted?
The first line of the PEM file gives it away:
head -2 privkey.pem is enough to check.
Removing the passphrase
openssl asks for the passphrase once and writes the key unencrypted in PKCS#8 format. openssl pkey works for RSA, EC and Ed25519 alike — the formerly common openssl rsa -in … -out … only handles RSA.
If an old program explicitly wants the BEGIN RSA PRIVATE KEY format:
Setting a passphrase
For storage in a backup or transport by mail the opposite direction makes sense:
If the key arrives as a PFX there is no intermediate step: -noenc when extracting delivers it unencrypted directly, see Create and extract a PFX file.
Protecting the unencrypted key
Without a passphrase the file itself is the secret. Therefore:
- Set permissions before the content goes in.
umask 077before the openssl command, orchmod 600 privkey.pemright after. Otherwise the file is briefly world-readable between writing andchmod. - Check the owner. Postfix and Dovecot read the key as root before dropping privileges —
root:rootwith600is enough. nginx too. If a service group needs access:640with exactly that group. - The encrypted copy does not belong next to it. An encrypted and an unencrypted version in the same directory protect nothing.
- Store it encrypted in the backup — that is where the passphrase makes sense, because nothing has to start unattended.
The start-up message when the key is still encrypted
Postfix then logs cannot get RSA private key from file "…": disabling TLS support (with smtpd_tls_chain_files: error loading private key) and switches TLS off: senders deliver unencrypted or get 454 4.7.0 TLS not available. nginx does not start at all or hangs at the prompt. After removing the passphrase, reload the service and check with openssl s_client that the new certificate is being served.