patch for PEAR::SOAP over HTTPS/SSL with certificates
| From: | (Jonathan Schilling) | Date: | Tue, 18 Mar 2003 18:43:00 +0000 |
| Subject: | patch for PEAR::SOAP over HTTPS/SSL with certificates | ||
| Groups: | php.soap | ||
| Request: | Send a blank email to php-soap+get-472@lists.php.net to get a copy of this message | ||
I finally have PEAR::SOAP over HTTPS/SSL with certificates working.
In order to do this, PEAR::SOAP needs to be enhanced to allow client
applications the ability to set arbitrary curl options.
I followed the approach that Peter Clarke suggested earlier for
this, but I have added a public interface to resolve an objection
from Arnaud Limbourg.
So here are my proposed patches to SOAP/Client.php and to
SOAP/Transport/HTTP.php:
*** Client.php..orig 2002-12-01 14:51:15.000000000 -0800
--- Client.php 2003-03-18 03:36:08.000000000 -0800
***************
*** 185,190 ****
--- 185,207 ----
}
/**
+ * curlSetopt
+ *
+ * To set curl options when using https, you use this function,
+ * passing it the same arguments as you would for curl_setopt.
+ *
+ * @param curl_setopt option
+ * @param curl_setopt value
+ *
+ * @access public
+ */
+ function curlSetopt($curl_setopt_option, $curl_setopt_value)
+ {
+ # store the curl_setopt parameters for retrieval before call
+ $this->__options['curlopt'][$curl_setopt_option] = $curl_setopt_value;
+ }
+
+ /**
* SOAP_Client::call
*
* the namespace parameter is overloaded to accept an array of
*** HTTP.php..orig 2002-10-19 12:43:54.000000000 -0700
--- HTTP.php 2003-03-18 03:44:41.000000000 -0800
***************
*** 360,366 ****
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
! curl_setopt($ch, CURLOPT_VERBOSE, 1);
$this->response = curl_exec($ch);
curl_close($ch);
--- 360,371 ----
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
! if (isset($options['curlopt'])) {
! reset($options['curlopt']);
! while (list($key, $val) = each ($options['curlopt'])) {
! curl_setopt($ch, $key, $val);
! }
! }
$this->response = curl_exec($ch);
curl_close($ch);
A sample client usage of the new interface would be:
$soapclient = new SOAP_Client("https://whatever.com/whatever.php");
$options = array('namespace' => 'urn:jls-whatever', 'trace'
=> 1);
$soapclient->curlSetopt(CURLOPT_VERBOSE, 1);
$soapclient->curlSetopt(CURLOPT_SSL_VERIFYHOST, 1);
$soapclient->curlSetopt(CURLOPT_SSL_VERIFYPEER, 1);
$soapclient->curlSetopt(CURLOPT_SSLCERT, "/home/jls/jls-both.pem");
$soapclient->curlSetopt(CURLOPT_SSLCERTPASSWD, "jls123");
$soapclient->curlSetopt(CURLOPT_CAINFO, "/home/jls/cacert.pem");
$ret = $soapclient->call(...)
The jls-both.pem file has to be a catenation of a signed certificate
request and a private key (see the curl --cert man page description).
Jonathan Schilling Caldera/SCO jls@sco.com