我正在使用XAMPP进行开发。最近,我将xampp的安装从旧版本升级到1.7.3。
现在,当我卷曲启用HTTPS的网站,我得到以下例外
致命错误:未捕获的异常'RequestCore_Exception'与消息
cURL资源:资源
id # 55;cURL错误:SSL证书有问题,请验证CA证书是否OK。细节:
SSL例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败(60)'
每个人都建议从PHP代码中使用一些特定的curl选项来解决这个问题。我觉得不应该这样。因为我的旧版本XAMPP没有任何问题,只是在安装新版本后才出现问题。
我需要帮助,以确定在我的PHP安装,Apache等设置更改可以解决这个问题。
来源:http://ademar.name/blog/2006/04/curl-ssl-certificate-problem-v.html
#Curl: SSL certificate problem, verify that the CA cert is OK#
###07 April 2006###
When opening a secure url with Curl you may get the following error:
SSL certificate problem, verify that the CA cert is OK
I will explain why the error and what you should do about it.
The easiest way of getting rid of the error would be adding the
following two lines to your script . This solution poses a security
risk tho.
//WARNING: this would prevent curl from detecting a 'man in the middle' attack
curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
Let see what this two parameters do. Quoting the manual.
CURLOPT_SSL_VERIFYHOST: 1 to check the existence of a common name in the SSL peer certificate. 2 to check the existence of a common name
and also verify that it matches the hostname provided.
CURLOPT_SSL_VERIFYPEER: FALSE to stop CURL from verifying the peer's certificate. Alternate certificates to verify against can be
specified with the CURLOPT_CAINFO option or a certificate directory
can be specified with the CURLOPT_CAPATH option.
CURLOPT_SSL_VERIFYHOST may also need to be TRUE or FALSE if
CURLOPT_SSL_VERIFYPEER is disabled (it defaults to 2). Setting
CURLOPT_SSL_VERIFYHOST to 2 (This is the default value) will garantee
that the certificate being presented to you have a 'common name'
matching the URN you are using to access the remote resource. This is
a healthy check but it doesn't guarantee your program is not being
decieved.
###Enter the 'man in the middle'###
Your program could be misleaded into talking to another server
instead. This can be achieved through several mechanisms, like dns or
arp poisoning ( This is a story for another day). The intruder can
also self-sign a certificate with the same 'comon name' your program
is expecting. The communication would still be encrypted but you would
be giving away your secrets to an impostor. This kind of attack is
called 'man in the middle'
###Defeating the 'man in the middle'###
Well, we need to to verify the certificate being presented to us is
good for real. We do this by comparing it against a certificate we
reasonable* trust.
If the remote resource is protected by a certificate issued by one of
the main CA's like Verisign, GeoTrust et al, you can safely compare
against Mozilla's CA certificate bundle which you can get from
http://curl.se/docs/caextract.html
Save the file cacert.pem somewhere in your server and set the
following options in your script.
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
curl_setopt ($ch, CURLOPT_CAINFO, "pathto/cacert.pem");
以上所有信息请访问:http://ademar.name/blog/2006/04/curl-ssl-certificate-problem-v.html