I'm wondering why there are different ways to use the openssl functions in PHP:
- pass a key as string (e.g. load it using
file_get_contents()
, or store it in an env variable) - pass a key file as a filename:
file:///var/keys/private_key
- load the key using
openssl_pkey_get_private()
and then free it withopenssl_free_key()
Is there a reason to prefer a specific method? Do the last solution better handle how the key is loaded/freed from memory (and if so, does that have a security impact)?