Support the ongoing development of Laravel.io →
posted 7 years ago
Requests
Last updated 2 years ago.
0

Ok, so found a couple of things for anyone else having this problem. Tried using CURLOPT_SSL_VERIFYPEER set to false, just to try to force the request - it's not a good idea to use in production as it ignores verification of the cert. However, this was still not working. var_dump on the request shows FALSE. By echoing out the curl_error() function, I got the following message which will help lead to the solution - it gives

"SSL: no alternative certificate subject name matches target host name 'www.myapi.com'"

So I'm following this route now - may be that I need to provide Laravel/PHP Curl with a link to a local copy of my cert... I'll post anything new I find.

0

So, for the moment leaving peer and host checking set to false allows me to get my data. I need to investigate why my SSL cert is giving conflicting information about its identity, but for the moment, this will work:

$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // <-- This turns off host verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // <-- And this turns off ssl verification
$output = curl_exec($ch);
return $output;

I'll post a fuller explanation when I've found one :-)

Wittner

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Wittner wittner Joined 12 Jan 2017

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.