From 79bcd8010c16a4d8c5472fce9fcc6a6e64297ef4 Mon Sep 17 00:00:00 2001 From: Etienne Bruines Date: Mon, 13 Jan 2020 10:50:30 +0100 Subject: [PATCH] Fix expected "Invalid Response" exceptions (#82) 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 --- src/LEOrder.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/LEOrder.php b/src/LEOrder.php index d10a854..159229c 100644 --- a/src/LEOrder.php +++ b/src/LEOrder.php @@ -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)) @@ -135,7 +140,7 @@ public function __construct($connector, $log, $certificateKeys, $basename, $doma $this->updateAuthorizations(); } } - else + catch (\Exception $e) { foreach ($this->certificateKeys as $file) {