19Ara
What is the difference of these two key files? [closed]
key1.pem
looks like this:
-----BEGIN PRIVATE KEY-----
encoded data
-----END PRIVATE KEY-----
key2.pem
looks like this:
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,28B2F38A64661706B0BC08CE244D8CA8
encoded data
-----END RSA PRIVATE KEY-----
Why?
For key1.pem
, I am using WSL and OpenSSL like so:
openssl req -x509 -nodes -days 3650 -newkey rsa:1024 -keyout key1.pem -out cert1.pem -config config.cnf
key2.pem
is generated with the Crypotgraphy Python library, like so:
key = rsa.generate_private_key(
public_exponent=65537,
key_size=RSA_KEY_SIZE,
)
with open(KEY_FILE_NAME, "wb") as f:
f.write(key.private_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PrivateFormat.TraditionalOpenSSL,
encryption_algorithm=serialization.BestAvailableEncryption(b"passphrase"),
))
What is the difference between these two keys?
How do you specify the encoding if that is what is different?
I need key2 to be encoded/formatted just like key1.
Solved:
I had to change this line
encryption_algorithm=serialization.BestAvailableEncryption(b"passphrase")
to
encryption_algorithm=serialization.NoEcryption()
And it's worth noting that NoEncryption is a class, so the ()
are required there.