NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Nusoap + client side certificate. Need help in debugging


Joined: 16 Feb 2010
Posts: 3
Reply with quote
Hello everybody,

After carefully going through all previous messages on this forum about the error I am getting (and not finding a solution) I decided to post it as a new topic

I have a requirement where I have to connect to a client side web service. I am using Nusoap to do it. To connect to the web service I have to use a .p12 certificate (a secure connection).

I am getting the following error message
Error
HTTP Error: cURL ERROR: 58: unable to use client certificate (no key found or wrong pass phrase?)url: ****** content_type:


I have tried to execute this code on widows/ubuntu, but the error remains unchanged.

Not sure if using a .p12 certificate is the root cause, because I really have no key file, and no passphrase, so i am using the same name for the sslcertfile and sslkeyfile.

This is how my code goes (built upon the standard template provided with nusoap distribution)

Code:

<?php
/*
 *   $Id: sslclient.php,v 1.1 2004/01/09 03:23:42 snichol Exp $
 *
 *   SSL client sample.
 *
 *   Service: SOAP endpoint
 *   Payload: rpc/encoded
 *   Transport: https
 *   Authentication: none
 */
require_once('nusoap.php');
$proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : '';
$proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : '';
$proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : '';
$proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : '';

  if(is_readable('cert.p12'))
  {
    echo 'The file is readable';
  }
  else
  {
    echo 'The file is not readable';
  }


$client = new nusoap_client('**********', false,$proxyhost, $proxyport, $proxyusername, $proxypassword);
$err = $client->getError();



 $client->setCredentials("", "", "certificate", array(
 'sslcertfile' => 'cert.p12',
 'sslkeyfile' =>  'cert.p12',
 'passphrase' => '',
 'verifypeer' => FALSE,
 'verifyhost' => FALSE
 ));


if ($err) {
   echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
}
$result = $client->call('TestFunction', array());//, 'http://arcweb.esri.com/v2', 'getVersion');
if ($client->fault) {
   echo '<h2>Fault</h2><pre>'; print_r($result); echo '</pre>';
} else {
   $err = $client->getError();
   if ($err) {
      echo '<h2>Error</h2><pre>' . $err . '</pre>';
   } else {
      echo '<h2>Result</h2><pre>'; print_r($result); echo '</pre>';
   }
}
echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';
?>






this is the debug output


Code:

Debug
2010-02-16 15:13:27.249731 nusoap_client: ctor wsdl= timeout=0 response_timeout=30
endpoint=string(64) "https://cws.centerpointenergy.com:3502/partner/customerData?wsdl"
2010-02-16 15:13:27.249873 nusoap_client: instantiate SOAP with endpoint at https://cws.centerpointenergy.com:3502/partner/customerData?wsdl
2010-02-16 15:13:27.249955 nusoap_client: setCredentials username= authtype=certificate certRequest=
array(5) {
  ["sslcertfile"]=>
  string(8) "file.pem"
  ["sslkeyfile"]=>
  string(8) "file.pem"
  ["passphrase"]=>
  string(0) ""
  ["verifypeer"]=>
  bool(false)
  ["verifyhost"]=>
  bool(false)
}
2010-02-16 15:13:27.250062 nusoap_client: call: operation=GetCustomerUsageHistory, namespace=http://tempuri.org, soapAction=, rpcParams=, style=rpc, use=encoded, endpointType=soap
params=array(0) {
}
headers=bool(false)
2010-02-16 15:13:27.250145 nusoap_client: serializing param array for operation GetCustomerUsageHistory
2010-02-16 15:13:27.250198 nusoap_client: wrapping RPC request with encoded method element
2010-02-16 15:13:27.250257 nusoap_client: In serializeEnvelope length=99 body (max 1000 characters)=<ns1846:GetCustomerUsageHistory xmlns:ns1846="http://tempuri.org"></ns1846:GetCustomerUsageHistory> style=rpc use=encoded encodingStyle=http://schemas.xmlsoap.org/soap/encoding/
2010-02-16 15:13:27.250315 nusoap_client: headers:
bool(false)
2010-02-16 15:13:27.250415 nusoap_client: namespaces:
array(0) {
}
2010-02-16 15:13:27.250490 nusoap_client: endpoint=https://cws.centerpointenergy.com:3502/partner/customerData?wsdl, soapAction=, namespace=http://tempuri.org, style=rpc, use=encoded, encodingStyle=http://schemas.xmlsoap.org/soap/encoding/
2010-02-16 15:13:27.250556 nusoap_client: SOAP message length=99 contents (max 1000 bytes)=<ns1846:GetCustomerUsageHistory xmlns:ns1846="http://tempuri.org"></ns1846:GetCustomerUsageHistory>
2010-02-16 15:13:27.250668 nusoap_client: transporting via HTTP
2010-02-16 15:13:27.251704 nusoap_client: sending message, length=99
2010-02-16 15:13:27.250777 soap_transport_http: ctor url=https://cws.centerpointenergy.com:3502/partner/customerData?wsdl use_curl= curl_options:
array(0) {
}
2010-02-16 15:13:27.250896 soap_transport_http: parsed URL scheme = https
2010-02-16 15:13:27.250969 soap_transport_http: parsed URL host = cws.centerpointenergy.com
2010-02-16 15:13:27.251040 soap_transport_http: parsed URL port = 3502
2010-02-16 15:13:27.251107 soap_transport_http: parsed URL path = /partner/customerData
2010-02-16 15:13:27.251195 soap_transport_http: parsed URL query = wsdl
2010-02-16 15:13:27.251259 soap_transport_http: set header Host: cws.centerpointenergy.com:3502
2010-02-16 15:13:27.251325 soap_transport_http: set header User-Agent: NuSOAP/0.7.3 (1.114)
2010-02-16 15:13:27.251385 soap_transport_http: set header Content-Type: text/xml; charset=ISO-8859-1
2010-02-16 15:13:27.251440 soap_transport_http: set header SOAPAction: ""
2010-02-16 15:13:27.251495 soap_transport_http: setCredentials username= authtype=certificate digestRequest=
array(0) {
}
2010-02-16 15:13:27.251553 soap_transport_http: certRequest=
array(5) {
  ["sslcertfile"]=>
  string(8) "file.pem"
  ["sslkeyfile"]=>
  string(8) "file.pem"
  ["passphrase"]=>
  string(0) ""
  ["verifypeer"]=>
  bool(false)
  ["verifyhost"]=>
  bool(false)
}
2010-02-16 15:13:27.251628 soap_transport_http: Authorization header not set for certificate
2010-02-16 15:13:27.251786 soap_transport_http: entered send() with data of length: 99
2010-02-16 15:13:27.251845 soap_transport_http: connect connection_timeout 0, response_timeout 30, scheme https, host cws.centerpointenergy.com, port 3502
2010-02-16 15:13:27.251910 soap_transport_http: connect using cURL
2010-02-16 15:13:27.251975 soap_transport_http: setCurlOption option=10002, value=
string(64) "https://cws.centerpointenergy.com:3502/partner/customerData?wsdl"
2010-02-16 15:13:27.252043 soap_transport_http: setCurlOption option=52, value=
int(1)
2010-02-16 15:13:27.252102 soap_transport_http: setCurlOption option=42, value=
int(1)
2010-02-16 15:13:27.252160 soap_transport_http: setCurlOption option=19913, value=
int(1)
2010-02-16 15:13:27.252219 soap_transport_http: setCurlOption option=13, value=
int(30)
2010-02-16 15:13:27.252276 soap_transport_http: set cURL SSL verify options
2010-02-16 15:13:27.252328 soap_transport_http: setCurlOption option=64, value=
int(0)
2010-02-16 15:13:27.252386 soap_transport_http: setCurlOption option=81, value=
int(0)
2010-02-16 15:13:27.252443 soap_transport_http: set cURL certificate options
2010-02-16 15:13:27.252496 soap_transport_http: setCurlOption option=64, value=
bool(false)
2010-02-16 15:13:27.252555 soap_transport_http: setCurlOption option=81, value=
bool(false)
2010-02-16 15:13:27.252649 soap_transport_http: setCurlOption option=10025, value=
string(8) "file.pem"
2010-02-16 15:13:27.252738 soap_transport_http: setCurlOption option=10087, value=
string(8) "file.pem"
2010-02-16 15:13:27.252821 soap_transport_http: setCurlOption option=10026, value=
string(0) ""
2010-02-16 15:13:27.252913 soap_transport_http: cURL connection set up
2010-02-16 15:13:27.253010 soap_transport_http: set header Content-Length: 99
2010-02-16 15:13:27.253082 soap_transport_http: HTTP request: POST /partner/customerData?wsdl HTTP/1.0
2010-02-16 15:13:27.253152 soap_transport_http: HTTP header: Host: cws.centerpointenergy.com:3502
2010-02-16 15:13:27.253223 soap_transport_http: HTTP header: User-Agent: NuSOAP/0.7.3 (1.114)
2010-02-16 15:13:27.253311 soap_transport_http: HTTP header: Content-Type: text/xml; charset=ISO-8859-1
2010-02-16 15:13:27.253381 soap_transport_http: HTTP header: SOAPAction: ""
2010-02-16 15:13:27.253443 soap_transport_http: HTTP header: Content-Length: 99
2010-02-16 15:13:27.253541 soap_transport_http: Skip cURL header Host: cws.centerpointenergy.com:3502
2010-02-16 15:13:27.253621 soap_transport_http: Skip cURL header Content-Length: 99
2010-02-16 15:13:27.253693 soap_transport_http: setCurlOption option=10023, value=
array(3) {
  [0]=>
  string(32) "User-Agent: NuSOAP/0.7.3 (1.114)"
  [1]=>
  string(42) "Content-Type: text/xml; charset=ISO-8859-1"
  [2]=>
  string(14) "SOAPAction: """
}
2010-02-16 15:13:27.253778 soap_transport_http: set cURL HTTP headers
2010-02-16 15:13:27.253850 soap_transport_http: setCurlOption option=47, value=
int(1)
2010-02-16 15:13:27.253930 soap_transport_http: setCurlOption option=10015, value=
string(99) "<ns1846:GetCustomerUsageHistory xmlns:ns1846="http://tempuri.org"></ns1846:GetCustomerUsageHistory>"
2010-02-16 15:13:27.254011 soap_transport_http: set cURL POST data
2010-02-16 15:13:27.254082 soap_transport_http: set cURL payload
2010-02-16 15:13:27.254161 soap_transport_http: send and receive with cURL
2010-02-16 15:13:27.289294 soap_transport_http: cURL ERROR: 58: unable to use client certificate (no key found or wrong pass phrase?)<br>url: https://cws.centerpointenergy.com:3502/partner/customerData?wsdl<br>content_type: <br>http_code: 0<br>header_size: 0<br>request_size: 0<br>filetime: -1<br>ssl_verify_result: 0<br>redirect_count: 0<br>total_time: 0<br>namelookup_time: 0<br>connect_time: 0.031<br>pretransfer_time: 0<br>size_upload: 0<br>size_download: 0<br>speed_download: 0<br>speed_upload: 0<br>download_content_length: -1<br>upload_content_length: -1<br>starttransfer_time: 0<br>redirect_time: 0<br>
2010-02-16 15:13:27.289505 soap_transport_http: end of send()
2010-02-16 15:13:27.289709 nusoap_client: Error: HTTP Error: cURL ERROR: 58: unable to use client certificate (no key found or wrong pass phrase?)<br>url: https://cws.centerpointenergy.com:3502/partner/customerData?wsdl<br>content_type: <br>http_code: 0<br>header_size: 0<br>request_size: 0<br>filetime: -1<br>ssl_verify_result: 0<br>redirect_count: 0<br>total_time: 0<br>namelookup_time: 0<br>connect_time: 0.031<br>pretransfer_time: 0<br>size_upload: 0<br>size_download: 0<br>speed_download: 0<br>speed_upload: 0<br>download_content_length: -1<br>upload_content_length: -1<br>starttransfer_time: 0<br>redirect_time: 0<br>




Please help me out there

-Thanks
View user's profileFind all posts by gautamSend private message
getting same error


Joined: 15 Sep 2010
Posts: 1
Reply with quote
Hi Gautam,

Did you find any solution for this ? I am getting same error. is it related with type of certificate or keyfile..?
Plz help me if you know...
View user's profileFind all posts by mohit_shahSend private message


Joined: 16 Feb 2010
Posts: 3
Reply with quote
Hi Mohit, i remember solving the problem. You need to hack with the nusoap.php code. Ill try to look for the code and paste it here, gimme some time

Gautam
View user's profileFind all posts by gautamSend private message


Joined: 01 Mar 2011
Posts: 1
Reply with quote
gautam wrote:
Hi Mohit, i remember solving the problem. You need to hack with the nusoap.php code. Ill try to look for the code and paste it here, gimme some time

Gautam


Sorry but the same problem!
Code:

if ($WSINDIRIZZO['idTipo']==2) {
//   echo "WSINDIRIZZO['idTipo'] :".$WSINDIRIZZO['idTipo']."<br>";//TEST
   $client->setUseCurl($useCURL);
   $client->loadWSDL();
   $client->setCredentials("","","certificate", array(
      //"cainfofile" => $sslPath . $caPath ,//OPTIONAL
      "sslcertfile" => realpath("eMax.pem"),
      "sslkeyfile" =>  realpath("eMax.pem"),
      "passphrase" =>  "",
      //"certpassword" => "",//OPTIONAL
      "verifypeer" => 0, //OPTIONAL
      "verifyhost" => 0 //OPTIONAL
       )
   );
}



and answer:
Code:

HTTP Error: cURL ERROR: 58: unable to use client certificate (no key found or wrong pass phrase?)
url: https://weg.rm.enel.it:443/axis/rpcEdi.do/urn:SoapEdi
content_type:
http_code: 0
header_size: 0
request_size: 0
filetime: -1
ssl_verify_result: 0
redirect_count: 0
total_time: 0
namelookup_time: 0
connect_time: 0.016
pretransfer_time: 0
size_upload: 0
size_download: 0
speed_download: 0
speed_upload: 0
download_content_length: -1
upload_content_length: -1
starttransfer_time: 0
redirect_time: 0

Please help me too!!
View user's profileFind all posts by paladinuxSend private message


Joined: 31 May 2012
Posts: 1
Reply with quote
Hi Gautam,

I've the same problem, have you solved it ?

Thank you in advance,
View user's profileFind all posts by lryoSend private message
Nusoap + client side certificate. Need help in debugging
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic