PHP twist error: "Unknown SSL protocol error due to ..."

I have extreme difficulty with PHP curl. I try to open the site: https://www.novaprostaffing.com/np/index.jsp via PHP curl, but it continues to lead to the following error: "Unknown SSL protocol error due to www.novaprostaffing.com"

My function is this:

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 tried to make several fixes, including:

  • Forcing curls to version 3
  • Setting CURLOPT_SSL_VERIFYPEER and CURLOPT_SSL_VERIFYHOST to 0
  • Checking for curls 7.34. I was told that there is an error in this version, but I am on curl 7.19.1.

None of this has been done. If you have an idea how to fix this, it would be very helpful!

+5
source share
3 answers

The server speaks only TLS 1.0 and attempting to connect with SSL 2.0 or SSL 3.0 will result in an error. This means that installing version 3 is not the same with this server. In addition, the certificate chain is incomplete. The server provides only a leaf certificate, not intermediate certificates to a trusted root. This will cause the verification to fail.

0
source

Try setting the cURL option CURLOPT_SSLVERSION . Some time ago I had the same problem, it did the trick for me :)

 curl_setopt($ch, CURLOPT_SSLVERSION, 3); // 1, 2 or 3 
+2
source

You tried another https-url and saw if it worked? Here are 3 common reasons

  • Destination site is not like protocol
  • Destination site not like cipher
  • SSL private secret
0
source

Source: https://habr.com/ru/post/1203974/


All Articles