5

I having extreme difficulty with PHP curl. I am attempting to open a site: https://www.novaprostaffing.com/np/index.jsp through PHP curl, but it keeps yielding the following error: "Unknown SSL protocol error in connection to www.novaprostaffing.com"

My function is as follows:

function getUrl($url) {
    $ch = curl_init();


    curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');


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

    curl_setopt($ch, CURLOPT_URL, $url);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

    $buffer = curl_exec($ch);

    if (!$buffer)
       {
       echo "cURL error number:" .curl_errno($ch);
       echo " and url is $url and cURL error:" . curl_error($ch);

        }
    curl_close($ch);
    return $buffer;
}

I have attempted multiple fixes including:

  1. Forcing curl to version 3
  2. Setting CURLOPT_SSL_VERIFYPEER & CURLOPT_SSL_VERIFYHOST to 0
  3. Checking to see if was on curl 7.34. I was told there was a bug on this version, but I am on curl 7.19.1

None of the above worked. If you have any idea how to fix this, it would be much appreciated!

1
  • 2
    Try it with curl_setopt($ch, CURLOPT_SSLVERSION, 1); This sets the version to TLSv1 (not SSLv1) Commented Oct 3, 2014 at 23:01

3 Answers 3

2

Try setting the cURL option CURLOPT_SSLVERSION. I had the same problem a while ago, this did the trick for me :)

curl_setopt($ch, CURLOPT_SSLVERSION, 3); // 1, 2 or 3
Sign up to request clarification or add additional context in comments.

Comments

1

The server speaks only TLS 1.0 and trying to connect with SSL 2.0 or SSL 3.0 will cause the error you see. This means setting the version to 3 is exactly the wrong thing with this server. Apart from that the certificate chain is incomplete. The server only provides the leaf certificate, not the intermediate certificates until the trusted root. This will cause verification to fail.

Comments

-1

Did you try some other https url and see if that worked ? Here are 3 common causes

  1. Destination Site Does Not Like the Protocol
  2. The Destination Site Does Not Like the Cipher
  3. The SSL Private Key Has Expired

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.