cURL and SSL

[email protected] (Sasan Rose) Wed, 07 Mar 2012 12:36:38 +0330
Newsgroups php.soap
Message-ID <[email protected]>
--------------enigCB1B4A3DF758A3E4358744D6
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

Hi,
I want to change a SOAP call to curl due to ssl timeout bug of PHP Soap.
My PHP version is PHP 5.2.6-1+lenny13 with Suhosin-Patch 0.9.6.2. I'm
using the following SOAP call and it's handling SSL very good:

$client =3D new SoapClient('https://92.X.X.X:8443', array('trace' =3D>
True, 'local_cert' =3D> 'BehnamCa/newkey.pem'));

But when i want to use cURL and overwrite the __doRequest function using
the following code:

$curl =3D curl_init($location);

curl_setopt($curl, CURLOPT_VERBOSE, TRUE);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl, CURLOPT_POST, TRUE);
curl_setopt($curl, CURLOPT_POSTFIELDS, $request);
curl_setopt($curl, CURLOPT_HEADER, FALSE);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
curl_setopt($curl, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt($curl, CURLOPT_CAPATH, '/home/sasan/CA2/BehnamCa/');
curl_setopt($curl, CURLOPT_SSLCERT, '/home/sasan/CA2/BehnamCa/newkey.pem'=
);
curl_setopt($curl, CURLOPT_SSLCERTTYPE, 'PEM');
curl_setopt($curl, CURLOPT_SSLKEY, '/home/sasan/CA2/BehnamCa/private.key'=
);
curl_setopt($curl, CURLOPT_CAINFO, '/home/sasan/CA2/BehnamCa/private.crt'=
);

$response =3D curl_exec($curl);

I'm receiving the following:

* About to connect() to 92.X.X.X port 8443 (#0)
*   Trying 92.X.X.X... * connected
* Connected to 92.X.X.X (92.X.X.X) port 8443 (#0)
* successfully set certificate verify locations:
*   CAfile: /home/sasan/CA2/BehnamCa/private.crt
  CApath: /home/sasan/CA2/BehnamCa/
* SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate
verify failed
* Closing connection #0
string(146) "SSL certificate problem, verify that the CA cert is OK.
Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate
verify failed"

As you can see, i'm trying every possible way to tell curl about my
keys, but still no success. Am i doing something wrong or this is a bug?


--------------enigCB1B4A3DF758A3E4358744D6
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJPVyUeAAoJEIsqDhgqiVntUncP/0JpeIISbOFnrbC8s8jZinmG
k2TZGY+/eDdYaLEUhg/0kDSIGoja+38UH7rwnx88HpjIdf6CSyJudZaDQXMt7lZl
kRkzbioxtTKzS4/OfvC+o8V50btSKXbeCFFnySLK9ZSDjQPAweN0g0+Urzk0gCTU
wWE7G/6SjWFAD3ceaZWJ/xNVfYtzjMAfYQDl2otMc8qww0hi4K4oyAEgj9FMDGw3
3IWLylovMttiiXs654W8odHyoSM+IPQ19Qob40w6ukk6tVsM3hgg6aKC3EwBH2/O
uzGtwKMvsXksnjwknnydmM6w751hkm71dT3sm36Cg9kLQz79WFwI3w144pUEoPnV
rTNUNfpjUBJOnVxg4Pk7/7DJvV8rNEpfzDfwJCM4b6v9HP+1LNHkSCLLNlmCyY7B
87lh8fpN4tBA7hBdlL+lbX7sGlfUiia8OHQMgX5Mf3L3muke/YC4UP6m/5wsKfTp
iWQ9YQ71Pe1dS2tIPMKwF1IuSbgqH7BpRXQqul/WY3mJD+gIfVxSP8No3re96Ktv
UVz/cgf3QPAqw77I2KlwPBk6SS13rOgkd5FyLLb1iYmDju4FdyM5qs7l/JVBs0iR
aas5lp6NXsofv+hgBQTLiW6TCcSzL+5SC8Vj2l76LlEHTEt2okrqLQkQxOmxa7FY
BBOtO3xgYPtJ6CmNJVUF
=AFWv
-----END PGP SIGNATURE-----

--------------enigCB1B4A3DF758A3E4358744D6--