When I use openssl genrsa -out yourdomain.key 2048
command to generate a key. I understand the yourdomain.key file contains both the private and public keys. But when I check the content of this key file, it starts and ends with -----BEGIN PRIVATE KEY-----
and -----END PRIVATE KEY-----
, which gives feeling that this file is just the private key. Why is that? This makes me very confused.
If I want to encrypt a message using private key, do I apply the entire yourdomain.key
key? Or should I extract the private key part from it and use that?