0

Update 2:

print_r(curl_error($ch));

OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to 10.10.10.10:8339

I am running on a corporate network with WAMP installed. I tried connecting to an internet API using Restlet Client and I am able to make GET request without any issues.

I tried the API calls using browser request and it works fine.

I am unable to make these API calls using PHP CURL request in WAMP server on my local.

I tried using proxy enabled in CURL but no luck. I tried enabling ERROR_Reporting(E_ALL) but can't see any errors too.

Here is my code.

$url = "https://10.10.10.10:8339/beta/targets/1234234123/isolated/1567687263?samples=true";
$username="apiuser";
$password="apipassword";
//$proxy = 'proxy:8080';
//$proxyauth = 'proxyuser:proxypassword';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
//curl_setopt($ch, CURLOPT_PROXY, $proxy);
//curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
print_r($output);
//print_r($info);
curl_close($ch);

The output for the above is blank

enter image description here

Karthik Malla
  • 5,570
  • 12
  • 46
  • 89

1 Answers1

1

The problem you have is that you're connecting to an HTTPS server without specifying the hostname. Therefore, it isn't possible to verify the hostname which is part of HTTPS.

The best thing to do would be to use a hostname. And, if you're using self-signed certificates, install them on your server so they can be validated.

In lieu of that, you can disable this checking in cURL:

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

See also: https://stackoverflow.com/a/15237205/362536

Brad
  • 159,648
  • 54
  • 349
  • 530