Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

Commit

Permalink
Fix expected "Invalid Response" exceptions (#82)
Browse files Browse the repository at this point in the history
The connector throws exceptions for non-200 status codes, so checking it in normal flow is
no longer an option. We need to try-catch it to be sure. 

Fixes #78
Fixes #79
  • Loading branch information
EtienneBruines authored and yourivw committed Jan 13, 2020
1 parent a2de17b commit 79bcd80
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/LEOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,14 @@ public function __construct($connector, $log, $certificateKeys, $basename, $doma
$this->orderURL = file_get_contents($this->certificateKeys['order']);
if (filter_var($this->orderURL, FILTER_VALIDATE_URL))
{
$get = $this->connector->get($this->orderURL);
if($get['status'] === 200 && $get['body']['status'] != "invalid")
try
{
$get = $this->connector->get($this->orderURL);
if($get['body']['status'] == "invalid")
{
throw new \RuntimeException('Order status is invalid');
}

$orderdomains = array_map(function($ident) { return $ident['value']; }, $get['body']['identifiers']);
$diff = array_merge(array_diff($orderdomains, $domains), array_diff($domains, $orderdomains));
if(!empty($diff))
Expand All @@ -135,7 +140,7 @@ public function __construct($connector, $log, $certificateKeys, $basename, $doma
$this->updateAuthorizations();
}
}
else
catch (\Exception $e)
{
foreach ($this->certificateKeys as $file)
{
Expand Down

0 comments on commit 79bcd80

Please sign in to comment.