Kelunik\AcmeClient\Commands\Auto::checkAndIssue PHP Method

checkAndIssue() private method

private checkAndIssue ( array $certificate, string $server, string $storage ) : Generator
$certificate array certificate configuration
$server string server to use for issuance
$storage string storage directory
return Generator
    private function checkAndIssue(array $certificate, $server, $storage)
    {
        $domainPathMap = $this->toDomainPathMap($certificate["paths"]);
        $domains = array_keys($domainPathMap);
        $commonName = reset($domains);
        $args = [PHP_BINARY, $GLOBALS["argv"][0], "check", "--server", $server, "--storage", $storage, "--name", $commonName, "--names", implode(",", $domains)];
        $command = implode(" ", array_map("escapeshellarg", $args));
        $process = new Process($command);
        $result = (yield $process->exec(Process::BUFFER_ALL));
        if ($result->exit === 0) {
            // No need for renewal
            (yield new CoroutineResult(self::STATUS_NO_CHANGE));
            return;
        }
        if ($result->exit === 1) {
            // Renew certificate
            $args = [PHP_BINARY, $GLOBALS["argv"][0], "issue", "--server", $server, "--storage", $storage, "--domains", implode(",", $domains), "--path", implode(PATH_SEPARATOR, array_values($domainPathMap))];
            if (isset($certificate["user"])) {
                $args[] = "--user";
                $args[] = $certificate["user"];
            }
            if (isset($certificate["bits"])) {
                $args[] = "--bits";
                $args[] = $certificate["bits"];
            }
            $command = implode(" ", array_map("escapeshellarg", $args));
            $process = new Process($command);
            $result = (yield $process->exec(Process::BUFFER_ALL));
            if ($result->exit !== 0) {
                throw new AcmeException("Unexpected exit code ({$result->exit}) for '{$command}'." . PHP_EOL . $result->stdout . PHP_EOL . PHP_EOL . $result->stderr);
            }
            (yield new CoroutineResult(self::STATUS_RENEWED));
            return;
        }
        throw new AcmeException("Unexpected exit code ({$result->exit}) for '{$command}'." . PHP_EOL . $result->stdout . PHP_EOL . PHP_EOL . $result->stderr);
    }