protected getKeyResource ( string | resource $key, string $password = null ) : resource | ||
$key | string | resource | |
$password | string | |
return | resource | OpenSSL key resource |
protected function getKeyResource($key, $password = null)
{
if (is_resource($key)) {
return $key;
}
$resource = openssl_pkey_get_public($key) ?: openssl_pkey_get_private($key, $password);
if ($resource === false) {
throw new RuntimeException('Could not read key resource: ' . openssl_error_string());
}
return $resource;
}