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:
Niklas Keller
2016-10-22 11:41:34 +02:00
parent c6d9c2016c
commit 253d3f476b
2 changed files with 19 additions and 0 deletions

View File

@@ -185,6 +185,8 @@ class Auto implements Command {
$storage,
"--name",
$commonName,
"--names",
implode(",", $domains),
];
$command = implode(" ", array_map("escapeshellarg", $args));

View File

@@ -45,6 +45,18 @@ class Check implements Command {
$this->climate->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) {
yield new CoroutineResult(0);
return;
@@ -70,6 +82,11 @@ class Check implements Command {
"defaultValue" => 30,
"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,
],
];
}
}