1

I am having difficulty curling an HTTPS url that uses TLS 1.2, in my curl operation- I post my login data into the website and save it in cookiefile. The error message I am getting is this:

"API Error:SSL connect error"

I have tried setting curl_setopt($ch, CURLOPT_POST) to 6 but that does not seem to work, any suggestions?

Versions I am using:

OpenSSL version is 1.0.2b CURL version is 7.49.1 PHP is 5.5 Here is the code:

    public function curl_request($url, $data, $method = 'GET', $headers = array(), $ssl_verify = false)
    {
            $ch = curl_init();

            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, $ssl_verify);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $ssl_verify);
            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
            curl_setopt($ch, CURLOPT_TIMEOUT, 20);
            curl_setopt($ch, CURLOPT_FAILONERROR, false);
            curl_setopt($ch, CURLOPT_HTTP200ALIASES, range(400, 599));
            curl_setopt($ch, CURLINFO_HEADER_OUT, true);


            if ($method == 'POST')
            {
                    curl_setopt($ch, CURLOPT_POST, 6);
                    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
            }

            $resp  = curl_exec($ch);      

            if(curl_errno($ch))
            {
                    throw new Exception('Unleashed API Error:' . curl_error($ch));
            }

            //print("<pre>" . print_r($resp, true). "</pre>")

            $info = curl_getinfo($ch);

            curl_close($ch);

            $output = array();
            $output['resp'] = $resp;
            $output['info'] = $info;
Marcin
  • 11
  • 3

1 Answers1

0

OpenSSL version is 0.9.8b

There is no support for TLS 1.2 in OpenSSL 0.9.8. You need at least OpenSSL version 1.0.1.

Steffen Ullrich
  • 114,247
  • 10
  • 131
  • 172
  • Thank you, I just updated the OpenSSL, should that have resolved the issue or is there something else I've missed? – Marcin Aug 02 '16 at 12:56
  • @Marcin: if you not only updated the OpenSSL binary but also curl so that it uses this library then at least the problem if no support for TLS 1.2 should be resolved. – Steffen Ullrich Aug 02 '16 at 18:29