diff --git a/lib/Handler/CertificateEngine/CfsslHandler.php b/lib/Handler/CertificateEngine/CfsslHandler.php index 759500d9f9..7b70667d27 100644 --- a/lib/Handler/CertificateEngine/CfsslHandler.php +++ b/lib/Handler/CertificateEngine/CfsslHandler.php @@ -375,25 +375,52 @@ private function checkBinaries(): array { ->setTip('Run occ libresign:install --cfssl'), ]; } - $return = []; - $version = str_replace("\n", ', ', trim(`$binary version`)); - if (strpos($version, InstallService::CFSSL_VERSION) === false) { + $version = shell_exec("$binary version"); + if (!is_string($version) || empty($version)) { + return [ + (new ConfigureCheckHelper()) + ->setErrorMessage(sprintf( + 'Failed to run the command "%s" with user %s', + "$binary version", + get_current_user() + )) + ->setResource('cfssl') + ->setTip('Run occ libresign:install --cfssl') + ]; + } + preg_match_all('/: (?.*)/', $version, $matches); + if (!$matches || !isset($matches['version']) || count($matches['version']) !== 2) { + return [ + (new ConfigureCheckHelper()) + ->setErrorMessage(sprintf( + 'Failed to identify cfssl version with command %s', + "$binary version" + )) + ->setResource('cfssl') + ->setTip('Run occ libresign:install --cfssl') + ]; + } + if (strpos($matches['version'][0], InstallService::CFSSL_VERSION) === false) { return [ (new ConfigureCheckHelper()) ->setErrorMessage(sprintf( 'Invalid version. Expected: %s, actual: %s', InstallService::CFSSL_VERSION, - $version + $matches['version'][0] )) ->setResource('cfssl') ->setTip('Run occ libresign:install --cfssl') ]; } + $return = []; $return[] = (new ConfigureCheckHelper()) ->setSuccessMessage('CFSSL binary path: ' . $binary) ->setResource('cfssl'); $return[] = (new ConfigureCheckHelper()) - ->setSuccessMessage('CFSSL: ' . $version) + ->setSuccessMessage('CFSSL version: ' . $matches['version'][0]) + ->setResource('cfssl'); + $return[] = (new ConfigureCheckHelper()) + ->setSuccessMessage('Runtime: ' . $matches['version'][1]) ->setResource('cfssl'); return $return; }