8

I'm using curl to send an xml file over https to the rightmove API - they supplied me with all the certificates.

I am getting the error :

60SSL certificate problem: unable to get local issuer certificateResult =

I have tried everything i have found on every other stackoverflow post similar and nothing is working, i have tried downloading the old cacert.pem and changed the files in php.ini - ive installed my personal information file andcreated a certificate on the browser and local machine and nothing is removing the error 60.

This is my PHP :

<?php
  $xml = file_get_contents("myxml.xml");

  $ch = curl_init();

  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
  curl_setopt ($ch, CURLOPT_CAINFO, dirname(__FILE__).'\mypem.pem');

  curl_setopt($ch, CURLOPT_URL, "https://adfapi.adftest.rightmove.com/v1/property/sendpropertydetails");
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_POST, 1);

  curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
  curl_setopt($ch, CURLOPT_REFERER, 'https://adfapi.adftest.rightmove.com/v1/property/sendpropertydetails');
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt ($ch, CURLOPT_VERBOSE , 1);

  $ch_result = curl_exec($ch);
print curl_errno($ch);
print curl_error($ch);
  echo "Result = ".$ch_result;
  curl_close($ch);

?>

this has had me banging my head for days, i would be very grateful for any assistance.

5
  • 1
    Try setting curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); and remove curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); Commented Mar 21, 2016 at 13:16
  • @Indrajit Thanks indrajit, but the api requires authentication Commented Mar 21, 2016 at 13:30
  • Presumably you're not getting the same error in your browser. Either you're not up to date with your patching or you've installed a version of PHP which is not correctly configured for your platform. Commented Mar 21, 2016 at 14:55
  • Im getting this error locally, on my web server and on my server at work.@symcbean, but yes you are correct, i can navigate therein browser no problem. Commented Mar 21, 2016 at 15:01
  • Still not been able to solve this after a full day trying Commented Mar 21, 2016 at 15:43

3 Answers 3

9

For my particular case i needed to add the keyfile, sslcert and cert password.

   //$xml = file_get_contents("thexmlfile.xml");
  $xml= $propertyXml->asXML();
  $ch = curl_init();

    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
    curl_setopt($ch, CURLOPT_CAINFO, getcwd() . '\pemfile.pem');

  curl_setopt($ch, CURLOPT_URL, "https://adfapi.adftest.rightmove.com/v1/property/sendpropertydetails");
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_POST, 1);
  curl_setopt($ch, CURLOPT_SSH_PRIVATE_KEYFILE, getcwd() . '\myjks.jks');
  curl_setopt($ch, CURLOPT_SSLCERT, getcwd() . '\pemfile.pem');
  curl_setopt($ch, CURLOPT_SSLCERTPASSWD, "thesslpassword");
  curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
  curl_setopt($ch, CURLOPT_REFERER, "https://adfapi.adftest.rightmove.com/v1/property/sendpropertydetails");
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt ($ch, CURLOPT_VERBOSE , 1);

 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

  $ch_result = curl_exec($ch);
print curl_errno($ch);
print curl_error($ch);
  echo "Result = ".$ch_result;
  curl_close($ch);
Sign up to request clarification or add additional context in comments.

1 Comment

Can you please paste the whole curl request please. I am struggling too with Curl Request for Rightmove for couple of days.
4

It is failing as curl is unable to verify the certificate provided by the server.

There are two options to get this to work:

1 Allows curl to make insecure connections, that is curl does not verify the certificate.

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

2 Add the root CA (the CA signing the server certificate) in php.ini

curl.cainfo=/path/to/cacert.pem

You should use option 2 as thats the option that ensures that you are connecting to secure ftp server.

5 Comments

I tired option 2 with cacert.pem (multiple ones i found on the internet from other posts) and it doesn't change anything.
And ofcourse the api returns auth failed if i try to not verify the host
when i change the curl.cainfo i get this : 60SSL certificate problem: unable to get local issuer certificateResult =
@GazSmith using curl ssl check this link
Thanks @walkingRed, although i still having an authentication issue from rightmoves api so the certificates must be wrong somewhere.
0

I was getting the same "SSL certificate problem: unable to get local issuer certificateResult" error with HTTP GET to a remote https site. I only needed to provide the CA cert to php curl, ie CURLOPT_CAINFO:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CAINFO, "/path/to/CA_Bundle.crt");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$output = curl_exec($ch);

if (curl_errno($ch)) {
  $error_msg = curl_error($ch);
  print "curl_error: $error_msg <br>";
} else {
  print "output: $output<br>";
}

curl_close($ch);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.