Omayr
Omayr

Reputation: 2019

php cURL unable to retrieve xml from (openssl) https address

My task is to retrieve an xml from https://test24.highrisehq.com/tasks/upcoming.xml that is a secure connection and demands authentication. I am trying to achieve this using curl but I don't know why the username and password thing is not working for me. Here is my code:

$url = "https://test24.highrisehq.com/tasks/upcoming.xml"; 
$ch = curl_init();     
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: application/xml', 'Content-Type: application/xml'));
curl_setopt($ch, CURLOPT_USERPWD, "[email protected]:akhtar1234");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,true);
curl_setopt($ch, CURLOPT_CAINFO, "D:\wamp\www\xml\-.highrisehq");
//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_URL, $url);  


$result = curl_exec($ch);  

print_r($result); 

The problem is that when I set VERIFYPEER to true I get nothing displayed on the browser and when it is set to false I get HTTP Basic: Access denied. Both curl and openssl are enabled. The credentials in the code are correct, if anyone wants to use it he is more than welcome. Your help would be appreciated.

Regards

Umair

Upvotes: 0

Views: 730

Answers (1)

matthiasmullie
matthiasmullie

Reputation: 2083

Setting the CURLOPT_SSL_VERIFYPEER flag to false just indicates that you are not interested in validating the ssl certificate, and is not related to the HTTP authentication you're failing. If you want to enable the certificate verification, you might want to look into installing ca-bundle.

The real problem here currently is the HTTP verification. It just seems the credentials you provided (CURLOPT_USERPWD) do not grant you the required permissions. You'll have to contact them to gain working credentials.

Upvotes: 1

Related Questions