Skip to content

Commit dc3748b

Browse files
committed
Allow specifying a custom CA bundle
1 parent dc3ea83 commit dc3748b

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/Client.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,10 @@ public function getSoapResponse( $soapUrl, $content, $throwException = true ) {
11051105
curl_setopt( $cURLHandle, CURLOPT_RETURNTRANSFER, 1 );
11061106
curl_setopt( $cURLHandle, CURLOPT_TIMEOUT, self::$connectorTimeout );
11071107

1108+
if ( $this->settings->caPath ) {
1109+
curl_setopt( $cURLHandle, CURLOPT_CAINFO, $this->settings->caPath );
1110+
}
1111+
11081112
if ( $this->settings->ignoreSslErrors ) {
11091113
curl_setopt( $cURLHandle, CURLOPT_SSL_VERIFYPEER, 0 );
11101114
curl_setopt( $cURLHandle, CURLOPT_SSL_VERIFYHOST, 0 );
@@ -1955,6 +1959,10 @@ private function retrieveWsdl( $wsdlUrl ) {
19551959
curl_setopt( $wsdlCurl, CURLOPT_CONNECTTIMEOUT, self::$connectorTimeout );
19561960
curl_setopt( $wsdlCurl, CURLOPT_TIMEOUT, self::$connectorTimeout );
19571961

1962+
if ( $this->settings->caPath ) {
1963+
curl_setopt( $wsdlCurl, CURLOPT_CAINFO, $this->settings->caPath );
1964+
}
1965+
19581966
if ( $this->settings->ignoreSslErrors ) {
19591967
curl_setopt( $wsdlCurl, CURLOPT_SSL_VERIFYPEER, 0 );
19601968
curl_setopt( $wsdlCurl, CURLOPT_SSL_VERIFYHOST, 0 );

src/Settings.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ class Settings {
134134
*/
135135
public $organizationVersion;
136136

137+
/**
138+
* Path to the CA bundle.
139+
*
140+
* @var string
141+
*/
142+
public $caPath;
143+
137144
/**
138145
* @var bool
139146
*/
@@ -222,6 +229,11 @@ public function __construct( $settings ) {
222229
$this->organizationUrl = sprintf( '%s://%s%s/XRMServices/2011/Organization.svc', $serverUrlParts['scheme'], $serverUrlParts['host'], $urlPort );
223230
// loginUrl is set upon Client instantiation
224231
}
232+
233+
// Set the custom CA bundle path.
234+
if ( isset( $settings['caPath'] ) && is_readable( $settings['caPath'] ) ) {
235+
$this->caPath = $settings['caPath'];
236+
}
225237
}
226238

227239
/**

0 commit comments

Comments
 (0)