Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function challengeAuthorization(AuthorizationChallenge $challenge, $timeout = 180)
 {
     Assert::integer($timeout, 'challengeAuthorization::$timeout expected an integer. Got: %s');
     $payload = ['resource' => ResourcesDirectory::CHALLENGE, 'type' => $challenge->getType(), 'keyAuthorization' => $challenge->getPayload(), 'token' => $challenge->getToken()];
     if (!$this->directory) {
         $this->initializeDirectory();
     }
     $response = (array) $this->httpClient->signedRequest('POST', $challenge->getUrl(), $payload);
     // Waiting loop
     $endTime = time() + $timeout;
     while (time() <= $endTime && (!isset($response['status']) || 'pending' === $response['status'])) {
         sleep(1);
         $response = (array) $this->httpClient->signedRequest('GET', $challenge->getUrl());
     }
     if (!isset($response['status']) || 'valid' !== $response['status']) {
         throw new ChallengeFailedException($response);
     } elseif ('pending' === $response['status']) {
         throw new ChallengeTimedOutException($response);
     }
     return $response;
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function supports(AuthorizationChallenge $authorizationChallenge)
 {
     return 'dns-01' === $authorizationChallenge->getType();
 }