openssl_free_key expects parameter 1 to be resource

喜你入骨 提交于 2019-12-12 17:14:47

问题


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?


回答1:


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);


来源:https://stackoverflow.com/questions/17726342/openssl-free-key-expects-parameter-1-to-be-resource

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!