curl and https


I’m in a bind so I’m hoping the community can lend me a hand. Short overview. I’ve developed an application for a client, but to get to it I have to handshake through their SSO protocol, which sends xml data back and forth to authenticate users. They provided me with access to their test server and I put snippets and research together to come up with a curl script that works. Here that is (in part):

$request_xml =  "$data"; // this is the parsed xml that I am sending to their server requesting information
$ch = curl_init(""); // this is where I'm sending the request to

curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request_xml);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$response_xml = curl_exec($ch);

$xmlDoc = new DOMDocument();

$x = $xmlDoc->getElementsByTagName('scope');
foreach ($x AS $item)
          $scopeCode = $item->getAttribute("value"); // this gives me what I'm looking for, the value of the "scope" tag

As I said, this works flawlessly on their test server. So what’s the problem? When I went to deploy it they sprung on me that their production server is https not http. So I tried simply changing this line:

$ch = curl_init(""); // simply added the "s"

But all I get back now is a blank page. In doing additional research it seems that using curl with https is a bit tricky…but possible from what I can tell. Problem is I haven’t been able to do it myself! My client thinks that the problem lies with my server not accepting their SSL cert, but given what I’ve read on the subject, I tend to believe it is curl.

I have to figure this out by Monday, so I am hoping that someone can shed some light on this for me. It would be greatly appreciated indeed!

Thanks in advance.

It is likely you just need to update Curl package. There are different versions of the Curl package, some of versions support SSL and some not. You’ll need to updated package and check if updated package include SSL support.

Sponsor our Newsletter | Privacy Policy | Terms of Service