Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable29] chore: improve cfssl validation #3943

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions lib/Handler/CertificateEngine/CfsslHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,25 +391,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>.*)/', $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;
}
Expand Down
Loading