Friday, January 18, 2008

Using SSL and Web Services with WSF/PHP

Sometimes , when you want to send critical information using SOAP, you need to use https protocol. WSF/PHP buildin support for this. All you need to do it to provide some simple options and configure the WSClient object.

Following is an example on how to do that.

The options used to configure ssl are
CACert, clientCert, and passphrase.

CACert is the Certificate authrity's certificate.
clientCert is the client's certificate.
passphrase is the password.

You can configure the WSClient object with these options when using ssl.


$client = new WSClient(array( "to" => "some endpoint uri",
"CACert" => "cacert.pem"));


  1. I have tried to use this options to access ws over https but all I'm getting is "Message = Error , NO Response Received". I can normally access same ws over http.


  2. so.. I have tried the same and I got the same error... "Message = Error , NO Response Received". I don't know how to solve..

  3. i used a key with passphrase and i get the same error. and the logs have the following errors:

    Can't load key from buffer
    Private key cannot be loaded.
    Cannot support cipher.
    Message signing failed

  4. Hm,Looks like there is a problem loading your certificates. Could be due to some path issue. Did you have a look the a https sample.
    What platform you are working on.

  5. Is there a way to provide CACert directly as data instead of path to file?

    Current solution is pretty inconsistent (WSSecurityToken accepts ceritifcates as data while CACert/clientCert in WSClient require path to file).

  6. Hi,

    same problem, my ws call work in HTTP, but not in HTTPS (Message = Error , NO Response Received). I found this in the client log :
    [Mon Jan 28 16:18:13 2013] [info] Starting addressing out handler
    [Mon Jan 28 16:18:13 2013] [debug] http_transport_sender.c(241) ctx_epr:
    [Mon Jan 28 16:18:13 2013] [debug] http_transport_sender.c(776) using axis2 native http sender.
    [Mon Jan 28 16:18:13 2013] [debug] http_sender.c(494) msg_ctx_id:urn:uuid:ef0a33e6-695d-1e21-2453-d43d7e273c95
    [Mon Jan 28 16:18:13 2013] [debug] http_transport_utils.c(3794) No session map stored
    [Mon Jan 28 16:18:13 2013] [info] [ssl client] CA certificate not specified
    [Mon Jan 28 16:18:13 2013] [error] ssl/ssl_utils.c(50) Cannot find certificates
    [Mon Jan 28 16:18:13 2013] [error] ssl/ssl_stream.c(99) Error occurred in SSL engine
    [Mon Jan 28 16:18:13 2013] [error] http_client.c(294) Data stream creation failed for Host and 443 port
    [Mon Jan 28 16:18:13 2013] [error] http_client.c(560) Client data stream null or socket error for host and 443 port
    [Mon Jan 28 16:18:13 2013] [error] http_client.c(562) A read attempt(HTTP) for the reply without sending the request
    [Mon Jan 28 16:18:13 2013] [error] http_sender.c(1303) status_code < 0
    [Mon Jan 28 16:18:13 2013] [error] engine.c(171) Transport sender invoke failed
    [Mon Jan 28 16:18:13 2013] [error] /home/cedric/wso2-wsf-php-src-2.1.0/src/wsf_client.c(1696) [WSF/PHP] Response Payload NULL( Error number and code) => : 76 :: A read attempt(HTTP) for the reply without sending the request

    Best regards,

  7. Hi I am getting the following error. Can someone help me please, Thanks.

    [Fri Feb 08 07:04:47 2013] [info] No files in the path C:\xampp\wso2-wsf-php-bin-2.0.0-win32\wsf_c/services.
    [Fri Feb 08 07:04:47 2013] [info] [rampart][rampart_mod] rampart_mod initialized
    [Fri Feb 08 07:04:47 2013] [info] [rahas]Rahas module initialized
    [Fri Feb 08 07:04:47 2013] [info] Starting addressing out handler
    [Fri Feb 08 07:04:47 2013] [warning] ..\..\src\core\context\msg_ctx.c(1403) RampartClientConfiguration not set in message context
    [Fri Feb 08 07:04:47 2013] [info] [rampart][rampart_signature] Endorsing Token is not specified. No need to endorse
    [Fri Feb 08 07:04:47 2013] [info] [ssl client] Client certificate chain filenot specified
    [Fri Feb 08 07:05:07 2013] [error] ..\..\src\core\transport\http\sender\ssl\ssl_stream.c(162) SSL Error: Premature close