From 711972edc59f61f5b62b01827326e0859ddc9c8d Mon Sep 17 00:00:00 2001 From: Denis Zunke Date: Wed, 14 Dec 2016 14:30:45 +0100 Subject: [PATCH] #19 implement configuration to disable guzzle ssl verification (#20) * #19 add support to disable ssl verification at guzzle client * #19 set verify ssl to default true * Update configuration --- CHANGELOG | 4 ++++ DependencyInjection/Configuration.php | 3 +++ DependencyInjection/DZunkeSlackExtension.php | 1 + Resources/doc/configuration.md | 1 + Slack/Client.php | 2 +- Slack/Client/Connection.php | 25 ++++++++++++++++++++ 6 files changed, 35 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 50343b7..ee53a33 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +SlackBundle v2.1.0 +================== +- Add Support to disable SSL Verification at Guzzle Client + SlackBundle v2.0.0 ================== - (NOT BC) Feature: Upgrade to Guzzle 6 (thanks for Support @alister) diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index fe03c3f..f546e9f 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -30,6 +30,9 @@ public function getConfigTreeBuilder() ->min(1) ->info('The amount of retries for the connection if the Rate Limits of Slack are reached') ->end() + ->booleanNode('verify_ssl') + ->defaultTrue() + ->end() ->end(); $rootNode->append($this->addIdentities()); diff --git a/DependencyInjection/DZunkeSlackExtension.php b/DependencyInjection/DZunkeSlackExtension.php index b5f440b..84d1c70 100644 --- a/DependencyInjection/DZunkeSlackExtension.php +++ b/DependencyInjection/DZunkeSlackExtension.php @@ -49,6 +49,7 @@ protected function configureSlackConnection(array $config, ContainerBuilder $con $definition->addMethodCall('setEndpoint', [$config['endpoint']]); $definition->addMethodCall('setToken', [$config['token']]); $definition->addMethodCall('setLimitRetries', [$config['limit_retries']]); + $definition->addMethodCall('setVerifySsl', [$config['verify_ssl']]); } } diff --git a/Resources/doc/configuration.md b/Resources/doc/configuration.md index 3667633..d92292c 100644 --- a/Resources/doc/configuration.md +++ b/Resources/doc/configuration.md @@ -4,6 +4,7 @@ d_zunke_slack: endpoint: slack.com/api/ token: null # Required + verify_ssl: true # ssl verification at guzzle client # The amount of retries for the connection if the Rate Limits of Slack are reached limit_retries: 3 diff --git a/Slack/Client.php b/Slack/Client.php index a925624..97b10c1 100644 --- a/Slack/Client.php +++ b/Slack/Client.php @@ -92,7 +92,7 @@ protected function buildUri(Actions\ActionsInterface $action, array $requestPara */ protected function executeRequest(Uri $uri) { - $guzzle = new GuzzleClient(); + $guzzle = new GuzzleClient(['verify' => $this->connection->getVerifySsl()]); return $guzzle->request('GET', $uri); } diff --git a/Slack/Client/Connection.php b/Slack/Client/Connection.php index e99fe51..639338b 100644 --- a/Slack/Client/Connection.php +++ b/Slack/Client/Connection.php @@ -19,6 +19,11 @@ class Connection */ protected $limitRetries = 3; + /** + * @var bool + */ + private $verifySsl = true; + /** * @param string $endpoint * @return $this @@ -76,6 +81,26 @@ public function getLimitRetries() return $this->limitRetries; } + /** + * @param bool $verifySsl + * + * @return $this + */ + public function setVerifySsl($verifySsl) + { + $this->verifySsl = (bool) $verifySsl; + + return $this; + } + + /** + * @return bool + */ + public function getVerifySsl() + { + return $this->verifySsl; + } + /** * @return bool */