3

I'm trying to connect using curl in PHP to Pronto Cycle Share (using PHP 5.6.2). This site works in the browser and from command line curl.

According to SSL Labs, it is only accepting TLS 1.2.

In PHP, using CURL (version 7.28.1) PHP fails to negotiate and gives me Curl error: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure

Using file_get_contents, the code:

$ctx = stream_context_create([
'ssl' => [
    'crypto_method' => STREAM_CRYPTO_METHOD_TLS_CLIENT
  ],
]);
$html = file_get_contents($url, false, $ctx);

Returns:

Message:  file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure

print_r(OPENSSL_VERSION_TEXT) says OpenSSL 0.9.8r 8 Feb 2011, so that's fairly old. I'm using MAMP PRO on the Mac.

Is there any way to connect to this server using simple PHP methods?

Hannele
  • 9,301
  • 6
  • 48
  • 68
MattC
  • 313
  • 1
  • 3
  • 8

1 Answers1

1

Your version of cURL doesn't support TLS 1.2, you need to upgrade.

CURL_SSLVERSION_TLSv1_0 (4), CURL_SSLVERSION_TLSv1_1 (5) or CURL_SSLVERSION_TLSv1_2 (6) only work for PHP versions using curl 7.34 or newer.

Source

Sammitch
  • 30,782
  • 7
  • 50
  • 77
  • That only references the constants used to define a particular version. [CURL_SSLVERSION_TLSv1 has always been available](http://curl.haxx.se/libcurl/c/CURLOPT_SSLVERSION.html), and indicates TLS v 1.x – miken32 Jan 21 '16 at 22:24