Was done here for something else with @-suppression:
But I think just removing the function calls should be fine, since the keys are allegedly automatically freed now:
https://www.php.net/manual/en/function.openssl-free-key.php
This probably shouldn't be picked to all supported release branches though.