Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ class Client extends \SoapClient
*/
protected static $privateKey = null;

/**
* CA certificate
*/
protected static $privateKeyPassword = null;

/**
* Client certificate
*/
Expand Down Expand Up @@ -84,15 +89,23 @@ public static function setPrivateKey( $file )
{
self::$privateKey = $file;
}


/**
* Set private key
*/
public static function setPrivateKeyPassword( $password )
{
self::$privateKeyPassword = $password;
}

/**
* Set client cert
*/
public static function setClientCert( $file )
{
self::$clientCert = $file;
}

/**
* Set CA cert
*/
Expand Down Expand Up @@ -155,21 +168,25 @@ public function __construct( $params = array() )
if (array_key_exists('key', $params)) {
static::setPrivateKey($params['key']);
}


if (array_key_exists('keyPassword', $params)) {
static::setPrivateKeyPassword($params['keyPassword']);
}

if (array_key_exists('cert', $params)) {
static::setClientCert($params['cert']);
}

if (array_key_exists('ca_cert', $params)) {
static::setCaCert($params['ca_cert']);
}

$options = array(
'location' => $endpoint,
'cache_wsdl' => WSDL_CACHE_NONE,
'trace' => true
);

parent::__construct($wsdl, $options);
}

Expand Down Expand Up @@ -212,11 +229,14 @@ public function __doRequest( $request, $location, $action, $version, $one_way =

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

// https://forum.italia.it/t/sdicoop-configurazione-php-soapclient-soapserver-apache-per-invio-e-ricezione-di-test/5528/85
curl_setopt($ch, 226, false);

curl_setopt($ch, CURLOPT_SSLKEY, self::$privateKey);
if (self::$privateKeyPassword != null) {
curl_setopt($ch, CURLOPT_SSLKEYPASSWD, self::$privateKeyPassword);
}
curl_setopt($ch, CURLOPT_SSLCERT, self::$clientCert);
curl_setopt($ch, CURLOPT_CAINFO, self::$caCert);

Expand Down