Curl SSL not working

Hey all, I’m having some problems when connecting to an ssl url using curl. Normally I should get some json back but for some reason it’s not doing anything and curl_error() returns me a “connection timed out”. I’m unable to find out what might be causing the trouble.

The code so far:
[php]
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, “https://www.***.com/***/validate/7BFA32B2222222”);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, “[email protected]:12345”);
curl_setopt($ch, CURLOPT_HTTPGET, TRUE);
curl_setopt($ch, CURLOPT_PORT, 8443);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($ch, CURLOPT_TIMEOUT, 1000);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

$curlRes = curl_exec($ch);
$data = json_decode($curlRes, true);[/php]

Going to the URL in my browser spawns me a login window and after that returns me the json properly. Also url’s on another server (not SSL) do work. After thinking about what might be causing the problem (as I also had this when I disabled SSL for this URL) I contacted my host to open up some ports which they kindly did telling me that should resolve the issue but it didn’t, neither with SSL nor without are working. I hope someone can shine some light on what might be causing the trouble here.

Tey this example http://www.net24.co.nz/kb/article/AA-00246

Thanks for the reply richei! I have updated the code but so far it still doesn’t work for me. I still get a connection timed out issues. >:(

[php]
$url = “https://www.***.com/***/mymerchant/tx”;
$headers = array(“Content-Type: application/json”);

$curl = curl_init();

if ($curl === false)
{
throw new Exception(’ cURL init failed’);
}

curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_USERPWD, “[email protected]:12345”);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_CAPATH, getcwd()."/cacert.pem");
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt($curl, CURLOPT_PORT, 8443);
curl_setopt($curl, CURLOPT_HTTPGET, TRUE);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($curl, CURLOPT_TIMEOUT, 60);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

$curlRes = curl_exec($curl);
$data = json_decode($curlRes, true);
print_r($data);[/php]

Got it solved, seems the hosting company didn’t open the right ports after all. Thanks for the help! :slight_smile:

Sponsor our Newsletter | Privacy Policy | Terms of Service