MAMP SSL错误:“错误:14077410:SSL例程:SSL23_GET_SERVER_HELLO:sslv3警报握手失败” [英] MAMP SSL error: "error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure"
问题描述
我在OS X Yosemite上使用MAMP在我的本地机器上开发网站。该网站是在HTTPS上运行的API的客户端应用程序。当我尝试从PHP调用API时,我会收到此错误:
I am using MAMP on OS X Yosemite to develop a website on my local machine. The website is a client application for an API that runs on HTTPS. I keep getting this error when I try to call the API from PHP:
error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
同样的代码在服务器上工作,但网站已经在生产中,所以我需要能够创建一个单独的开发环境。我得到完全相同的错误,无论我用cURL或 file_get_contents
调用API。我可以在命令行中使用cURL或在我的浏览器中加载URL,它工作正常。我花了几个小时阅读和尝试所有其他解决方案,我可以在这个网站和其他地方找到,他们都没有工作。有没有人看到这个问题?
The same code works on the server, but the site is already in production so I need to be able to create a separate development environment. I get exactly the same error whether I call the API with cURL or file_get_contents
. I can use cURL on the command line or load the URL in my browser and it works fine. I've spent hours reading through and trying all the other solutions I could find on this site and elsewhere, and none of them have worked. Has anyone else seen this problem?
更新:我终于找到一个解决方案在我最后一个沟通工作刚刚发布这个问题,这样一个痛苦的过程,我发布它希望它可以帮助别人避免这种发辫的灾难。我的解决方案如下。
Update: I finally found a solution in my last ditch effort just before posting this question, but it was such a painful process that I'm posting it anyway in hopes it can help someone else avoid this hair-tearing catastrophe. My solution is below.
推荐答案
解决方案:
-
brew install openssl
- 下载并解压最新的 cURL
-
在cURL源目录中:
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
, curl_init
和 curl_exec
之间:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
说明:
找到解决方案的路径以此网站,它描述了MAMP上的一个不同的SSL错误,并建议用
- prefix = / Applications / MAMP / Library /
覆盖MAMP使用的一个。我试过这个,但它没有工作。后来,有东西让我学习cURL编译选项,我注意到在编译它时指定不同版本的OpenSSL的说明。我决定尝试(答应自己,这是最后的尝试,然后我会放弃)。我安装了一个最新的OpenSSL包与Homebrew,它有用的安装后信息说:
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/lib
CPPFLAGS: -I/usr/local/opt/openssl/include
我在cURL编译选项中看到的,它为上述指定了正确的语法:
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
我在 - prefix = / Applications / MAMP / Library /
中添加了后面的 code>和
make install
,重新启动MAMP,并释放叹息。
I added back in the --prefix=/Applications/MAMP/Library/
, followed by the usual make
and make install
, restarted MAMP, and sighed with relief.
我后来发现,我从另一个网站投入的一个cURL选项也是必要的,以避免不同的SSL错误(SSL证书问题:无法获取本地发行人证书)。将 CURLOPT_SSL_VERIFYPEER
设置为false解决了一个对我。
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.
这篇关于MAMP SSL错误:“错误:14077410:SSL例程:SSL23_GET_SERVER_HELLO:sslv3警报握手失败”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!