Question

I have this code:

openssl_pkcs12_read($p12buf, $p12cert, $decPass);
openssl_pkey_export($p12cert['pkey'], $pemkey); 
openssl_sign($toSign, $signature, $pemkey, OPENSSL_ALGO_SHA1);
openssl_free_key($pemkey);

I get this warning:

Warning (2): openssl_free_key() expects parameter 1 to be resource, string given

How can i get rid of it or what I am doing wrong?

Was it helpful?

Solution

openssl_free_key require the result (resource) of openssl_pkey_get_private or openssl_pkey_get_public

$key = openssl_pkey_get_private($keyFile, $passphrase);
openssl_free_key($key);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top