Throw exception if no challenges are returned at all

Signed-off-by: Florian Aders <eleras@froxlor.org>
This commit is contained in:
Florian Aders
2016-02-02 11:17:04 +01:00
parent cdb00a76ce
commit 1814407bfd

View File

@@ -100,9 +100,13 @@ class lescript
array("resource" => "new-authz", "identifier" => array("type" => "dns", "value" => $domain))
);
if (!array_key_exists('challenges', $response)) {
throw new RuntimeException("No challenges received for $domain. Whole response: ".json_encode($response));
}
// choose http-01 challange only
$challenge = array_reduce($response['challenges'], function($v, $w) { return $v ? $v : ($w['type'] == 'http-01' ? $w : false); });
if(!$challenge) throw new \RuntimeException("HTTP Challenge for $domain is not available. Whole response: ".json_encode($response));
if(!$challenge) throw new RuntimeException("HTTP Challenge for $domain is not available. Whole response: ".json_encode($response));
$this->log("Got challenge token for $domain");
$location = $this->client->getLastLocation();