public function pollForChallenge(string $location): Promise {
        return call(function () use ($location) {
            do {
                /** @var Response $response */
                $response = yield $this->acmeClient->get($location);
                $body = yield $response->getBody();
                $data = json_decode($body);

                if ($data->status === 'pending') {
                    if (!$response->hasHeader('retry-after')) {
                        // throw new AcmeException("Protocol Violation: No Retry-After Header!");

                        yield new Delayed(1000);
                        continue;
                    }

                    $waitTime = $this->parseRetryAfter($response->getHeader('retry-after'));
                    $waitTime = max($waitTime, 1);

                    yield new Delayed($waitTime * 1000);

                    continue;
                }

                if ($data->status === 'invalid') {
                    $errors = [];

                    foreach ($data->errors ?? [] as $error) {
                        $message = $error->title ?? '???';

                        if ($error->detail ?? '') {
                            $message .= ' (' . $error->detail . ')';
                        }

                        $errors[] = $message;
                    }

                    throw new AcmeException('Challenge marked as invalid: ' . ($errors ? \implode(', ', $errors) : ('Unknown error: ' . $body)));
                }

                if ($data->status === 'valid') {
                    break;
                }

                throw new AcmeException("Invalid challenge status: {$data->status}.");
            } while (1);
        });
    }