在XAMPP中为CURL启用SSL支持

Sto*_*oic 8 xampp ssl https curl

我正在使用编码的PHP脚本,它需要对CURL的SSL支持.

我目前正在使用XAMPP进行本地开发,并且需要知道如何更新默认CURL,以便通过它启用SSL.

我正在寻找升级/支持的原因是我收到以下错误,当谷歌搜索等等.我明白我的机器上的CURL不支持SSL.

SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Run Code Online (Sandbox Code Playgroud)

有人对我有任何建议吗?我当前的本地服务器配置:

XAMPP 1.7.3 cURL支持 启用
cURL信息 7.19.6
Apache版本 Apache/2.2.14(Win32)DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4的Perl/v5.10.1
加载模块 芯mod_win32 mpm_winnt http_core mod_so mod_actions mod_alias中mod_asis mod_auth_basic mod_auth_digest的mod_authn_default mod_authn_file模块mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_cgi一样的mod_dav mod_dav_fs可以mod_dav_lock的mod_dir mod_env mod_headers中mod_include负责mod_info mod_isapi mod_log_config mod_mime mod_negotiation模块的mod_rewrite mod_setenvif mod_ssl的mod_status的mod_vhost_alias mod_autoindex_color mod_php5的mod_perl mod_apreq2
SERVER_SIGNATURE Apache/2.2.14(Win32)DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1服务器在localhost端口80
SERVER_SOFTWARE Apache/2.2.14(Win32)DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1

Eag*_*ird 10

Not supported on your machine? The error you've posted means that CURL wasn't able to verify the SSL certificate for the remote server, and doesn't necessarily point to a specific inadequacy of your machine. In my previous experience with CURL, it defaults to not accepting/trusting any certificates. Depending on your setup and what you plan to do with it, you may want to trust a single, self-signed certificate [[Cannot verify self-signed certs!]] (e.g. from another machine you run) or you may want to trust a true Certificate Authority (which will enable verification of any certs signed by that CA). This tutorial is fairly straightforward, provided you're familiar with how to change CURL's settings: http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/

如果采用该路径,您可以选择根CA,但如果您只是在两台自己的机器之间保护传输,则只需将CURL设置为信任其他计算机的证书即可.

另一方面,如果你确实有一些更深层次的SSL问题,它可能是由许多事情引起的,比如在没有SSL支持的情况下构建.如果您正在制作,配置和编译自己的CURL版本,您可能需要查看有关SSL的主题的http://curl.haxx.se/docs/faq.html,包括

http://curl.haxx.se/docs/sslcerts.htmlhttp://curl.haxx.se/docs/faq.html#What_certificates_do_I_need_when

请注意后一个链接(FAQ)无法验证自签名证书.如果您要连接到自己的另一台服务器,则需要由CA和CURL信任的CA证书对其证书进行签名,以使连接成功.如果您只需要获得签名,或者您可以设置自己的CA,那么就有免费的CA(根据我的经验,只有十倍的时间才能让已经设置好的人签名).如果其他服务器正在托管一个处理"真实世界"(金钱,产品,个人信息等)的安全网站,那么它的证书应该是或者你应该让它由可信任的CA签署(VISA,Equifax,Comodo,您可以在每个浏览器中找到受信任的根CA列表.

我已经介绍了我可以回应这个错误,但如果这些都没有帮助,那么关于您的设置和系统的更多信息可能会有所帮助.:)


Chr*_*row 8

一个非常简单的解决方案对我有用,就是打电话:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
Run Code Online (Sandbox Code Playgroud)

在致电之前:

 curl_exec():
Run Code Online (Sandbox Code Playgroud)

在php文件中.

我相信这会禁用SSL证书的所有验证.

  • ...并且通过禁用证书的验证,您可以对潜在的MITM攻击敞开大门,而SSL/TLS则旨在防范这些攻击.不要这样做! (8认同)
  • 对.我应该在答案中更多地关注这一点.只有在你没有处理任何重要的事情时才这样做.我在localhost上使用它来访问我个人编程的网站. (5认同)