Soap client option allows setting CURLOPT_SSLVERSION
This commit is contained in:
parent
7ab8771989
commit
a9f11beb83
|
@ -4,7 +4,6 @@ namespace BeSimple\SoapClient\Curl;
|
||||||
|
|
||||||
use BeSimple\SoapClient\Curl\Http\HttpAuthenticationBasicOptions;
|
use BeSimple\SoapClient\Curl\Http\HttpAuthenticationBasicOptions;
|
||||||
use BeSimple\SoapClient\Curl\Http\HttpAuthenticationDigestOptions;
|
use BeSimple\SoapClient\Curl\Http\HttpAuthenticationDigestOptions;
|
||||||
use BeSimple\SoapClient\Curl\Http\SslCertificateOptions;
|
|
||||||
use Exception;
|
use Exception;
|
||||||
|
|
||||||
class Curl
|
class Curl
|
||||||
|
@ -141,6 +140,11 @@ class Curl
|
||||||
curl_setopt($curlSession, CURLOPT_CAPATH, $sslCertificateOptions->hasCertificateAuthorityPath());
|
curl_setopt($curlSession, CURLOPT_CAPATH, $sslCertificateOptions->hasCertificateAuthorityPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($options->hasSslVersion()) {
|
||||||
|
curl_setopt($curlSession, CURLOPT_SSLVERSION, $options->getSslVersion());
|
||||||
|
}
|
||||||
|
|
||||||
$executeSoapCallResponse = $this->executeHttpCall($curlSession, $options);
|
$executeSoapCallResponse = $this->executeHttpCall($curlSession, $options);
|
||||||
|
|
||||||
$httpRequestHeadersAsString = curl_getinfo($curlSession, CURLINFO_HEADER_OUT);
|
$httpRequestHeadersAsString = curl_getinfo($curlSession, CURLINFO_HEADER_OUT);
|
||||||
|
@ -159,7 +163,7 @@ class Curl
|
||||||
$httpResponseCode
|
$httpResponseCode
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!is_integer($httpResponseCode) || $httpResponseCode >= 400 || $httpResponseCode === 0) {
|
if (!is_int($httpResponseCode) || $httpResponseCode >= 400 || $httpResponseCode === 0) {
|
||||||
|
|
||||||
return new CurlResponse(
|
return new CurlResponse(
|
||||||
$this->normalizeStringOrFalse($httpRequestHeadersAsString),
|
$this->normalizeStringOrFalse($httpRequestHeadersAsString),
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
namespace BeSimple\SoapClient\Curl;
|
namespace BeSimple\SoapClient\Curl;
|
||||||
|
|
||||||
|
use BeSimple\SoapClient\Curl\Http\HttpAuthenticationBasicOptions;
|
||||||
use BeSimple\SoapClient\Curl\Http\HttpAuthenticationDigestOptions;
|
use BeSimple\SoapClient\Curl\Http\HttpAuthenticationDigestOptions;
|
||||||
use BeSimple\SoapClient\Curl\Http\HttpAuthenticationInterface;
|
use BeSimple\SoapClient\Curl\Http\HttpAuthenticationInterface;
|
||||||
use BeSimple\SoapClient\Curl\Http\HttpAuthenticationBasicOptions;
|
|
||||||
use BeSimple\SoapClient\Curl\Http\SslCertificateOptions;
|
use BeSimple\SoapClient\Curl\Http\SslCertificateOptions;
|
||||||
use BeSimple\SoapClient\SoapServerProxy\SoapServerProxy;
|
use BeSimple\SoapClient\SoapServerProxy\SoapServerProxy;
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ class CurlOptions
|
||||||
private $proxy;
|
private $proxy;
|
||||||
private $httpAuthentication;
|
private $httpAuthentication;
|
||||||
private $sslCertificateOptions;
|
private $sslCertificateOptions;
|
||||||
|
private $sslVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $userAgent
|
* @param string $userAgent
|
||||||
|
@ -31,6 +32,7 @@ class CurlOptions
|
||||||
* @param SoapServerProxy|null $proxy
|
* @param SoapServerProxy|null $proxy
|
||||||
* @param HttpAuthenticationInterface|null $httpAuthentication
|
* @param HttpAuthenticationInterface|null $httpAuthentication
|
||||||
* @param SslCertificateOptions|null $sslCertificateOptions
|
* @param SslCertificateOptions|null $sslCertificateOptions
|
||||||
|
* @param int $sslVersion
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$userAgent,
|
$userAgent,
|
||||||
|
@ -39,7 +41,8 @@ class CurlOptions
|
||||||
$connectionTimeout,
|
$connectionTimeout,
|
||||||
SoapServerProxy $proxy = null,
|
SoapServerProxy $proxy = null,
|
||||||
HttpAuthenticationInterface $httpAuthentication = null,
|
HttpAuthenticationInterface $httpAuthentication = null,
|
||||||
SslCertificateOptions $sslCertificateOptions = null
|
SslCertificateOptions $sslCertificateOptions = null,
|
||||||
|
$sslVersion = null
|
||||||
) {
|
) {
|
||||||
$this->userAgent = $userAgent;
|
$this->userAgent = $userAgent;
|
||||||
$this->followLocationMaxRedirects = $followLocationMaxRedirects;
|
$this->followLocationMaxRedirects = $followLocationMaxRedirects;
|
||||||
|
@ -48,6 +51,7 @@ class CurlOptions
|
||||||
$this->proxy = $proxy;
|
$this->proxy = $proxy;
|
||||||
$this->httpAuthentication = $httpAuthentication;
|
$this->httpAuthentication = $httpAuthentication;
|
||||||
$this->sslCertificateOptions = $sslCertificateOptions;
|
$this->sslCertificateOptions = $sslCertificateOptions;
|
||||||
|
$this->sslVersion = $sslVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUserAgent()
|
public function getUserAgent()
|
||||||
|
@ -123,4 +127,14 @@ class CurlOptions
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function hasSslVersion()
|
||||||
|
{
|
||||||
|
return $this->sslVersion !== null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSslVersion()
|
||||||
|
{
|
||||||
|
return $this->sslVersion;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,8 @@ class CurlOptionsBuilder
|
||||||
self::DEFAULT_CONNECTION_TIMEOUT,
|
self::DEFAULT_CONNECTION_TIMEOUT,
|
||||||
$soapClientOptions->getProxy(),
|
$soapClientOptions->getProxy(),
|
||||||
self::getHttpAuthOptions($soapClientOptions),
|
self::getHttpAuthOptions($soapClientOptions),
|
||||||
self::getSslCertificateOptions($soapClientOptions)
|
self::getSslCertificateOptions($soapClientOptions),
|
||||||
|
$soapClientOptions->getSslVersion()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,28 @@ class SoapClientOptionsBuilder
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $endpointLocation
|
||||||
|
* @param SoapServerAuthenticationInterface $authentication
|
||||||
|
* @return SoapClientOptions
|
||||||
|
*/
|
||||||
|
public static function createWithAuthenticationAndEndpointLocationAndSslVersionV3(
|
||||||
|
$endpointLocation,
|
||||||
|
SoapServerAuthenticationInterface $authentication
|
||||||
|
) {
|
||||||
|
return new SoapClientOptions(
|
||||||
|
SoapClientOptions::SOAP_CLIENT_TRACE_ON,
|
||||||
|
SoapClientOptions::SOAP_CLIENT_EXCEPTIONS_ON,
|
||||||
|
CurlOptions::DEFAULT_USER_AGENT,
|
||||||
|
SoapClientOptions::SOAP_CLIENT_COMPRESSION_NONE,
|
||||||
|
$authentication,
|
||||||
|
SoapClientOptions::SOAP_CLIENT_PROXY_NONE,
|
||||||
|
$endpointLocation,
|
||||||
|
false,
|
||||||
|
CURL_SSLVERSION_SSLv3
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param SoapServerAuthenticationInterface $authentication
|
* @param SoapServerAuthenticationInterface $authentication
|
||||||
* @param bool $resolveRemoteIncludes
|
* @param bool $resolveRemoteIncludes
|
||||||
|
|
|
@ -31,6 +31,7 @@ class SoapClientOptions
|
||||||
private $proxy;
|
private $proxy;
|
||||||
private $location;
|
private $location;
|
||||||
private $resolveRemoteIncludes;
|
private $resolveRemoteIncludes;
|
||||||
|
private $sslVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool $trace = self::SOAP_CLIENT_TRACE_ON|self::SOAP_CLIENT_TRACE_OFF
|
* @param bool $trace = self::SOAP_CLIENT_TRACE_ON|self::SOAP_CLIENT_TRACE_OFF
|
||||||
|
@ -41,6 +42,7 @@ class SoapClientOptions
|
||||||
* @param SoapServerProxy|null $proxy
|
* @param SoapServerProxy|null $proxy
|
||||||
* @param string|null $location
|
* @param string|null $location
|
||||||
* @param bool $resolveRemoteIncludes = self::SOAP_CLIENT_RESOLVE_REMOTE_INCLUDES_ON|self::SOAP_CLIENT_RESOLVE_REMOTE_INCLUDES_OFF
|
* @param bool $resolveRemoteIncludes = self::SOAP_CLIENT_RESOLVE_REMOTE_INCLUDES_ON|self::SOAP_CLIENT_RESOLVE_REMOTE_INCLUDES_OFF
|
||||||
|
* @param int $sslVersion
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$trace,
|
$trace,
|
||||||
|
@ -50,7 +52,8 @@ class SoapClientOptions
|
||||||
SoapServerAuthenticationInterface $authentication = null,
|
SoapServerAuthenticationInterface $authentication = null,
|
||||||
SoapServerProxy $proxy = null,
|
SoapServerProxy $proxy = null,
|
||||||
$location = null,
|
$location = null,
|
||||||
$resolveRemoteIncludes = false
|
$resolveRemoteIncludes = false,
|
||||||
|
$sslVersion = null
|
||||||
) {
|
) {
|
||||||
$this->trace = $trace;
|
$this->trace = $trace;
|
||||||
$this->exceptions = $exceptions;
|
$this->exceptions = $exceptions;
|
||||||
|
@ -60,6 +63,7 @@ class SoapClientOptions
|
||||||
$this->proxy = $proxy;
|
$this->proxy = $proxy;
|
||||||
$this->location = $location;
|
$this->location = $location;
|
||||||
$this->resolveRemoteIncludes = $resolveRemoteIncludes;
|
$this->resolveRemoteIncludes = $resolveRemoteIncludes;
|
||||||
|
$this->sslVersion = $sslVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTrace()
|
public function getTrace()
|
||||||
|
@ -154,4 +158,9 @@ class SoapClientOptions
|
||||||
|
|
||||||
return $optionsAsArray;
|
return $optionsAsArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSslVersion()
|
||||||
|
{
|
||||||
|
return $this->sslVersion;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ namespace BeSimple\SoapClient;
|
||||||
|
|
||||||
use BeSimple\SoapClient\Curl\CurlOptions;
|
use BeSimple\SoapClient\Curl\CurlOptions;
|
||||||
use BeSimple\SoapClient\SoapOptions\SoapClientOptions;
|
use BeSimple\SoapClient\SoapOptions\SoapClientOptions;
|
||||||
|
use BeSimple\SoapClient\SoapServerAuthentication\SoapServerAuthenticationBasic;
|
||||||
use BeSimple\SoapCommon\ClassMap;
|
use BeSimple\SoapCommon\ClassMap;
|
||||||
use BeSimple\SoapCommon\SoapOptions\SoapOptions;
|
use BeSimple\SoapCommon\SoapOptions\SoapOptions;
|
||||||
use BeSimple\SoapCommon\SoapOptionsBuilder;
|
use BeSimple\SoapCommon\SoapOptionsBuilder;
|
||||||
|
@ -87,6 +88,27 @@ class SoapClientBuilderTest extends PHPUnit_Framework_TestCase
|
||||||
self::assertInstanceOf(SoapClient::class, $soapClient);
|
self::assertInstanceOf(SoapClient::class, $soapClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testCreateOptionsWithAuthenticationAndEndpointLocationAndSslVersionV3()
|
||||||
|
{
|
||||||
|
$authentication = new SoapServerAuthenticationBasic('', '');
|
||||||
|
$soapClientOptions = SoapClientOptionsBuilder::createWithAuthenticationAndEndpointLocationAndSslVersionV3('', $authentication);
|
||||||
|
|
||||||
|
self::assertSame(CURL_SSLVERSION_SSLv3, $soapClientOptions->getSslVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testConstructSoapClientWithAuthenticationAndEndpointLocationAndSslVersionV3()
|
||||||
|
{
|
||||||
|
$authentication = new SoapServerAuthenticationBasic('', '');
|
||||||
|
$soapOptions = SoapOptionsBuilder::createWithDefaults(self::TEST_LOCAL_WSDL_UK);
|
||||||
|
|
||||||
|
$soapClient = $this->getSoapBuilder()->build(
|
||||||
|
SoapClientOptionsBuilder::createWithAuthenticationAndEndpointLocationAndSslVersionV3('', $authentication),
|
||||||
|
$soapOptions
|
||||||
|
);
|
||||||
|
|
||||||
|
self::assertInstanceOf(SoapClient::class, $soapClient);
|
||||||
|
}
|
||||||
|
|
||||||
private function getSoapBuilder()
|
private function getSoapBuilder()
|
||||||
{
|
{
|
||||||
return new SoapClientBuilder();
|
return new SoapClientBuilder();
|
||||||
|
|
Loading…
Reference in New Issue