From 73a3b0aee211aa945949c753bb375c8567132668 Mon Sep 17 00:00:00 2001 From: Bas Schipper Date: Tue, 8 Nov 2016 14:11:12 +0100 Subject: [PATCH 1/3] Added soap client proxy support --- lib/Transip/Api/SoapClientAbstract.php | 14 ++++++++++++++ lib/Transip/Client.php | 21 +++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/lib/Transip/Api/SoapClientAbstract.php b/lib/Transip/Api/SoapClientAbstract.php index 8dee9a0..7b08214 100644 --- a/lib/Transip/Api/SoapClientAbstract.php +++ b/lib/Transip/Api/SoapClientAbstract.php @@ -62,6 +62,20 @@ protected function soapClient(array $classMap, $parameters = array()) 'trace' => false, // can be used for debugging ); + $options = array_merge($options, $this->client->getSoapOptions()); + + if ($options['proxy_host']) { + $streamOptions = array( + 'ssl' => array( + 'SNI_enabled' => true, + 'SNI_server_name' => $endpoint + ) + ); + $streamContext = stream_context_create($streamOptions); + + $options['stream_context'] = $streamContext; + } + $wsdlUri = "https://{$endpoint}/wsdl/?service=" . $this->service; try { $this->soapClient = new \SoapClient($wsdlUri, $options); diff --git a/lib/Transip/Client.php b/lib/Transip/Client.php index f270373..c64eeab 100644 --- a/lib/Transip/Client.php +++ b/lib/Transip/Client.php @@ -49,6 +49,11 @@ class Client */ protected $privateKey; + /** + * Option to add aditional options to the SoapClient(http://php.net/manual/en/soapclient.soapclient.php) + */ + protected $soapOptions = array(); + /** * @param string $login * @param string $privateKey @@ -151,4 +156,20 @@ public function setMode($mode) throw new \Exception("$mode is not a available mode for this API."); } + + /** + * @return array + */ + public function getSoapOptions() + { + return $this->soapOptions; + } + + /** + * @param array $soapOptions + */ + public function setSoapOptions($soapOptions) + { + $this->soapOptions = $soapOptions; + } } From 9dccdcc7e20f9443344e940ab906eddd682c9164 Mon Sep 17 00:00:00 2001 From: Bas Schipper Date: Tue, 8 Nov 2016 14:22:45 +0100 Subject: [PATCH 2/3] Added soap client proxy support --- lib/Transip/Api/SoapClientAbstract.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Transip/Api/SoapClientAbstract.php b/lib/Transip/Api/SoapClientAbstract.php index 7b08214..24cfd36 100644 --- a/lib/Transip/Api/SoapClientAbstract.php +++ b/lib/Transip/Api/SoapClientAbstract.php @@ -64,7 +64,7 @@ protected function soapClient(array $classMap, $parameters = array()) $options = array_merge($options, $this->client->getSoapOptions()); - if ($options['proxy_host']) { + if (isset($options['proxy_host'])) { $streamOptions = array( 'ssl' => array( 'SNI_enabled' => true, From 1d2cc5520e0af28109022433743bb545b3d36878 Mon Sep 17 00:00:00 2001 From: Bas Schipper Date: Wed, 11 Jan 2017 12:19:51 +0100 Subject: [PATCH 3/3] Added php 5.6 sni support --- lib/Transip/Api/SoapClientAbstract.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/lib/Transip/Api/SoapClientAbstract.php b/lib/Transip/Api/SoapClientAbstract.php index 24cfd36..c51b2d9 100644 --- a/lib/Transip/Api/SoapClientAbstract.php +++ b/lib/Transip/Api/SoapClientAbstract.php @@ -64,17 +64,15 @@ protected function soapClient(array $classMap, $parameters = array()) $options = array_merge($options, $this->client->getSoapOptions()); - if (isset($options['proxy_host'])) { - $streamOptions = array( - 'ssl' => array( - 'SNI_enabled' => true, - 'SNI_server_name' => $endpoint - ) - ); - $streamContext = stream_context_create($streamOptions); - - $options['stream_context'] = $streamContext; - } + $streamOptions = array( + 'ssl' => array( + 'SNI_enabled' => true, + 'SNI_server_name' => $endpoint, + 'peer_name' => $endpoint, + ) + ); + $streamContext = stream_context_create($streamOptions); + $options['stream_context'] = $streamContext; $wsdlUri = "https://{$endpoint}/wsdl/?service=" . $this->service; try {