Renew if not all names are covered
Renew a certificate if not all names are covered by the current certificate yet. Adds a new `--names` option to `check` that makes `check` fail if not all names are covered. Resolves #34.
This commit is contained in:
@@ -185,6 +185,8 @@ class Auto implements Command {
|
|||||||
$storage,
|
$storage,
|
||||||
"--name",
|
"--name",
|
||||||
$commonName,
|
$commonName,
|
||||||
|
"--names",
|
||||||
|
implode(",", $domains),
|
||||||
];
|
];
|
||||||
|
|
||||||
$command = implode(" ", array_map("escapeshellarg", $args));
|
$command = implode(" ", array_map("escapeshellarg", $args));
|
||||||
|
|||||||
@@ -45,6 +45,18 @@ class Check implements Command {
|
|||||||
$this->climate->br();
|
$this->climate->br();
|
||||||
$this->climate->whisper(" Certificate is valid until " . date("d.m.Y", $cert->getValidTo()))->br();
|
$this->climate->whisper(" Certificate is valid until " . date("d.m.Y", $cert->getValidTo()))->br();
|
||||||
|
|
||||||
|
if ($args->exists("names")) {
|
||||||
|
$names = array_map("trim", explode(",", $args->get("names")));
|
||||||
|
$missingNames = array_diff($names, $cert->getNames());
|
||||||
|
|
||||||
|
if ($missingNames) {
|
||||||
|
$this->climate->comment(" The following names are not covered: " . implode(", ", $missingNames))->br();
|
||||||
|
|
||||||
|
yield new CoroutineResult(1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($cert->getValidTo() > time() + $args->get("ttl") * 24 * 60 * 60) {
|
if ($cert->getValidTo() > time() + $args->get("ttl") * 24 * 60 * 60) {
|
||||||
yield new CoroutineResult(0);
|
yield new CoroutineResult(0);
|
||||||
return;
|
return;
|
||||||
@@ -70,6 +82,11 @@ class Check implements Command {
|
|||||||
"defaultValue" => 30,
|
"defaultValue" => 30,
|
||||||
"castTo" => "int",
|
"castTo" => "int",
|
||||||
],
|
],
|
||||||
|
"names" => [
|
||||||
|
"longPrefix" => "names",
|
||||||
|
"description" => "Names that must be covered by the certificate identified based on the common name. Names have to be separated by commas.",
|
||||||
|
"required" => false,
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user