From 20027f4d697b2ae17f294b3080fe2eb4572c8645 Mon Sep 17 00:00:00 2001 From: iglocska Date: Mon, 14 Jun 2021 10:02:16 +0200 Subject: [PATCH] fix: [https] errors caught by the health element --- .../local_tool_connectors/MispConnector.php | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Lib/default/local_tool_connectors/MispConnector.php b/src/Lib/default/local_tool_connectors/MispConnector.php index 7a2b0bf..efd480e 100644 --- a/src/Lib/default/local_tool_connectors/MispConnector.php +++ b/src/Lib/default/local_tool_connectors/MispConnector.php @@ -104,13 +104,20 @@ class MispConnector extends CommonConnectorTools { $settings = json_decode($connection->settings, true); $http = new Client(); - $response = $http->post($settings['url'] . '/users/view/me.json', '{}', [ - 'headers' => [ - 'AUTHORIZATION' => $settings['authkey'], - 'Accept' => 'Application/json', - 'Content-type' => 'Application/json' - ] - ]); + try { + $response = $http->post($settings['url'] . '/users/view/me.json', '{}', [ + 'headers' => [ + 'AUTHORIZATION' => $settings['authkey'], + 'Accept' => 'Application/json', + 'Content-type' => 'Application/json' + ] + ]); + } catch (\Exception $e) { + return [ + 'status' => 0, + 'message' => __('Connection issue.') + ]; + } $responseCode = $response->getStatusCode(); if ($response->isOk()) { $status = 1;