private function getResourceUri(string $resource): Promise {
        // ACME MUST be served over HTTPS, but we use HTTP for testing …
        if (0 === strpos($resource, 'http://') || 0 === strpos($resource, 'https://')) {
            return new Success($resource);
        }

        if (!$this->directory) {
            return call(function () use ($resource) {
                yield $this->fetchDirectory();

                return $this->getResourceUri($resource);
            });
        }

        if (isset($this->directory[$resource])) {
            return new Success($this->directory[$resource]);
        }

        return new Failure(new AcmeException("Resource not found in directory: '{$resource}'."));
    }