From 2c2e1c4c7a94cdd3319c029e22e616df0853310e Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 11 Dec 2017 15:07:08 +0100 Subject: Catch the errors related to untrusted self signed certificates for federation * Added tests Signed-off-by: Roeland Jago Douma --- apps/federation/lib/BackgroundJob/GetSharedSecret.php | 7 ++++++- apps/federation/lib/BackgroundJob/RequestSharedSecret.php | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'apps/federation/lib/BackgroundJob') diff --git a/apps/federation/lib/BackgroundJob/GetSharedSecret.php b/apps/federation/lib/BackgroundJob/GetSharedSecret.php index 6090f521fcc..92bb31e369e 100644 --- a/apps/federation/lib/BackgroundJob/GetSharedSecret.php +++ b/apps/federation/lib/BackgroundJob/GetSharedSecret.php @@ -32,6 +32,8 @@ namespace OCA\Federation\BackgroundJob; use GuzzleHttp\Exception\ClientException; use GuzzleHttp\Exception\ConnectException; +use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Ring\Exception\RingException; use OC\BackgroundJob\JobList; use OC\BackgroundJob\Job; use OCA\Federation\DbHandler; @@ -197,7 +199,10 @@ class GetSharedSecret extends Job { } else { $this->logger->info($target . ' responded with a ' . $status . ' containing: ' . $e->getMessage(), ['app' => 'federation']); } - } catch (ConnectException $e) { + } catch (RequestException $e) { + $status = -1; // There is no status code if we could not connect + $this->logger->info('Could not connect to ' . $target, ['app' => 'federation']); + } catch (RingException $e) { $status = -1; // There is no status code if we could not connect $this->logger->info('Could not connect to ' . $target, ['app' => 'federation']); } catch (\Exception $e) { diff --git a/apps/federation/lib/BackgroundJob/RequestSharedSecret.php b/apps/federation/lib/BackgroundJob/RequestSharedSecret.php index a201c9dccb6..ad7504da7ad 100644 --- a/apps/federation/lib/BackgroundJob/RequestSharedSecret.php +++ b/apps/federation/lib/BackgroundJob/RequestSharedSecret.php @@ -33,6 +33,8 @@ namespace OCA\Federation\BackgroundJob; use GuzzleHttp\Exception\ClientException; use GuzzleHttp\Exception\ConnectException; +use GuzzleHttp\Exception\RequestException; +use GuzzleHttp\Ring\Exception\RingException; use OC\BackgroundJob\JobList; use OC\BackgroundJob\Job; use OCA\Federation\DbHandler; @@ -197,7 +199,10 @@ class RequestSharedSecret extends Job { } else { $this->logger->info($target . ' responded with a ' . $status . ' containing: ' . $e->getMessage(), ['app' => 'federation']); } - } catch (ConnectException $e) { + } catch (RequestException $e) { + $status = -1; // There is no status code if we could not connect + $this->logger->info('Could not connect to ' . $target, ['app' => 'federation']); + } catch (RingException $e) { $status = -1; // There is no status code if we could not connect $this->logger->info('Could not connect to ' . $target, ['app' => 'federation']); } catch (\Exception $e) { -- cgit v1.2.3