9

I'm trying to execute HTTPS request:

curl_setopt($curl, CURLOPT_URL, 'https://***.com');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_POST, false);
curl_setopt($curl, CURLOPT_COOKIEJAR, $cookiesFile);
curl_setopt($curl, CURLOPT_VERBOSE, true);
$out = curl_exec($curl);

After request, $out is empty, and I'm getting this log:

* About to connect() to ***.com port 443 (#0)
*   Trying *.*.*.*...
* connected
* Connected to ***.com (*.*.*.*) port 443 (#0)
* error:14077458:SSL routines:SSL23_GET_SERVER_HELLO:reason(1112)
* Closing connection #0

Why?

artem
  • 16,382
  • 34
  • 113
  • 189
  • whats your platform and version of php and openssl? check `phpinfo();` – Waygood Aug 12 '13 at 16:10
  • 5
    The **first hit on Google** points back to a question here on SO that explains why this happens: http://stackoverflow.com/questions/8619706/running-curl-with-openssl-0-9-8-against-openssl-1-0-0-server-causes-handshake-er - how's that for poor research. – fvu Aug 12 '13 at 16:10
  • @fvu, thanks, curl_setopt($ch, CURLOPT_SSLVERSION,3); worked for me. – artem Aug 12 '13 at 16:12
  • @Waygood, PHP 5.4.10, OpenSSL/0.9.8x, Mac OS X 10.8.4 – artem Aug 12 '13 at 16:14

2 Answers2

26

Fix:

curl_setopt($ch, CURLOPT_SSLVERSION,3); 
artem
  • 16,382
  • 34
  • 113
  • 189
  • Thanks a lot mate. just to add to this, as it is better to leverage SPL defined constants like this: `curl_setopt($ch, CURLOPT_SSLVERSION,CURL_SSLVERSION_SSLv3);` – codarrior Oct 20 '15 at 00:06
  • 1
    error:SSL: couldn't create a context: error:140A90C4:SSL routines:SSL_CTX_new:null ssl method passed – ninja Aug 10 '17 at 13:35
1

If you're using PRTG and get this error, go to settings and change from "SSL V2 or V3" to "SSL V3".

Josiah
  • 2,666
  • 5
  • 30
  • 40