SSL connection example,fails compared to cURL

  • Diego Gullo

    Diego Gullo - 2010-07-22


    I have some problems in connecting to a SSL resource from NuSoap and all the topics on the site do not give me enough clues or are old and related to old versions of the package.

    I have got a fully working cURL connection through SSL for a REST API. When I try to establish a connection with the same server for a SOAP API using NuSoap the script gives me a private key related error
    "HTTP Error: cURL ERROR: 58: unable to set private key file:"
    This error is definitely due to wrong coding of the test script or a bug as I am using the same client certificate, private key and password and I am disabling the verification of the host as I do not want to verify the CA certificate. The code can be found in this pastebin

    Apart from the above problem i wanted to check what is the right usage for setCredentials. When used in certificate mode it looks like the username and password fields are not really needed then you specify the authentication method => "certificate" and then provide the array of options that really are cURL options. What is then the relation between the setCredentials and setCurlOptions when you use both. Documentation does not provide this insight and details that show the exact relation between the two methods and the various options to connect to a resource. Are we supposed to use both ? I tried the above example with setCurlOption but it did not work. It looks like NuSoap does something in the background that is not really friendly to this case.

    I look forward for your comments and opinions

    Thanks for reading


  • Scott Nichol

    Scott Nichol - 2011-01-13

    soap_transport_http#connect does the authentication oriented curl calls, while the sendRequest method on that class applies any user-specified options.  The latter was added to allow people who find they need to do specific curl-related things to do so without changing their NuSOAP code.

  • Diego Gullo

    Diego Gullo - 2011-01-14

    Hi Snichol

    I managed to get it working by applying the setCredentials properly as per example

    $client = new soapclient($wsdl_url, 'wsdl');
    $err = $client->getError();
    if ($err) {
        echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
              //"cainfofile"  => $sslPath . $caPath , //OPTIONAL
              "sslcertfile"  => $sslPath . $sslcert,
              "sslkeyfile"  => $sslPath . $sslkey,
              "passphrase"  => "MySuperPassword",
              //"certpassword"  => "",//OPTIONAL
              "verifypeer"  => 0, //OPTIONAL
              "verifyhost"  => 0   //OPTIONAL

    At the moment i am stuck due to another problem so i will post a new thread.



Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks