Kelunik\AcmeClient\Commands\Issue::solveChallenge PHP Method

solveChallenge() private method

private solveChallenge ( AcmeService $acme, KeyPair $keyPair, $domain, $path )
$acme Kelunik\Acme\AcmeService
$keyPair Kelunik\Acme\KeyPair
    private function solveChallenge(AcmeService $acme, KeyPair $keyPair, $domain, $path)
    {
        list($location, $challenges) = (yield $acme->requestChallenges($domain));
        $goodChallenges = $this->findSuitableCombination($challenges);
        if (empty($goodChallenges)) {
            throw new AcmeException("Couldn't find any combination of challenges which this client can solve!");
        }
        $challenge = $challenges->challenges[reset($goodChallenges)];
        $token = $challenge->token;
        if (!preg_match("#^[a-zA-Z0-9-_]+\$#", $token)) {
            throw new AcmeException("Protocol violation: Invalid Token!");
        }
        $payload = $acme->generateHttp01Payload($keyPair, $token);
        $this->climate->whisper("    Providing payload at http://{$domain}/.well-known/acme-challenge/{$token}");
        $challengeStore = new ChallengeStore($path);
        try {
            (yield $challengeStore->put($token, $payload, isset($user) ? $user : null));
            (yield $acme->verifyHttp01Challenge($domain, $token, $payload));
            (yield $acme->answerChallenge($challenge->uri, $payload));
            (yield $acme->pollForChallenge($location));
            $this->climate->comment("    {$domain} is now authorized.");
            (yield $challengeStore->delete($token));
        } catch (Exception $e) {
            // no finally because generators...
            (yield $challengeStore->delete($token));
            throw $e;
        } catch (Throwable $e) {
            // no finally because generators...
            (yield $challengeStore->delete($token));
            throw $e;
        }
    }