Kelunik\Acme\AcmeService::doAnswerChallenge PHP Méthode

doAnswerChallenge() private méthode

Answers a challenge and signals that the CA should validate it.
private doAnswerChallenge ( string $location, string $keyAuth ) : Generator
$location string URI of the challenge
$keyAuth string key authorization
Résultat Generator coroutine resolved by Amp returning the decoded JSON response
    private function doAnswerChallenge($location, $keyAuth)
    {
        if (!is_string($location)) {
            throw new InvalidArgumentException(sprintf("\$location must be of type string, %s given.", gettype($location)));
        }
        if (!is_string($keyAuth)) {
            throw new InvalidArgumentException(sprintf("\$keyAuth must be of type string, %s given.", gettype($keyAuth)));
        }
        /** @var Response $response */
        $response = (yield $this->acmeClient->post($location, ["resource" => AcmeResource::CHALLENGE, "keyAuthorization" => $keyAuth]));
        if ($response->getStatus() === 202) {
            (yield new CoroutineResult(json_decode($response->getBody())));
            return;
        }
        throw $this->generateException($response);
    }