MAMP SSL error: "error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure"
The solution:
brew install openssl
- Download and unpack the latest cURL
In the cURL source directory:
LDFLAGS="-L/usr/local/opt/openssl/lib" CPPFLAGS="-I/usr/local/opt/openssl/include" ./configure --prefix=/Applications/MAMP/Library/
make
make install
- Restart MAMP
In PHP, between
curl_init
andcurl_exec
:curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
The explanation:
The path to finding the solution started with this site, which describes a different SSL error on MAMP, and suggests recompiling a fresh version of cURL with--prefix=/Applications/MAMP/Library/
to overwrite the one MAMP uses. I tried this but it didn't work. Later, something possessed me to study the cURL compile options, and I noticed instructions for specifying a different version of OpenSSL when compiling it. I decided to give it a try (promising myself that this was the last attempt and then I would give up). I installed an up to date OpenSSL package with Homebrew, and its helpful post-install info said:
If you build your own software and it requires this formula, you'll need to add to your build variables:LDFLAGS: -L/usr/local/opt/openssl/libCPPFLAGS: -I/usr/local/opt/openssl/include
That looked similar to something I saw in the cURL compile options, which specified the correct syntax for the above:
LDFLAGS="-L/usr/local/opt/openssl/lib" CPPFLAGS="-I/usr/local/opt/openssl/include" ./configure
I added back in the --prefix=/Applications/MAMP/Library/
, followed by the usual make
and make install
, restarted MAMP, and sighed with relief.
I later discovered that one of the cURL options I had thrown in from another website was also necessary to avoid a different SSL error ("SSL certificate problem: unable to get local issuer certificate"). Setting CURLOPT_SSL_VERIFYPEER
to false solved that one for me.
Here is a solution that works for me on MAMP Pro 3.5 running on OSX 10.11.1
In your PHP you may need to set the SSL version and the matching Cipher for curl_init()
:
curl_setopt($ch, CURLOPT_SSLVERSION, 1);curl_setopt($ch, CURLOPT_SSL_CIPHER_LIST, 'TLSv1');
For the exact parameters you can pass to CURLOPT_SSLVERSION
see: http://php.net/manual/en/function.curl-setopt.php
Also the following can display errors related to SSL versions being used to help find exact version conflict you have:
$error = curl_error($ch);echo $error;
More on this command: http://php.net/manual/en/ref.curl.php
Ive had the same problem. I solved it by instead using Apples preferred SecureTransport SSL program. The following worked for me:
- Download the latest curl (zip) version from here
- Go to your downloads folder and extract the zip file by double clicking on it. There will now be a folder with in your downloads folders with the extracted files.
- Open terminal and navigate to the folder `cd ~/Downloads/curl-folder-name'
- Then in terminal type
./configure --prefix=/Applications/MAMP/Library/ --with-darwinssl
make && make install
Restart MAMP and see if the changes worked. One way to check is to call the following on your MAMP php program in terminal:
/Applications/MAMP/bin/php/php5.5.14/bin/php -r 'echo json_encode(curl_version(), JSON_PRETTY_PRINT);'
You should see "ssl_version": "SecureTransport"