如何在Windows上为PHP全局设置CURLOPT_CAINFO? [英] How can I set CURLOPT_CAINFO globally for PHP on Windows?

查看:283
本文介绍了如何在Windows上为PHP全局设置CURLOPT_CAINFO?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以设置任何特定的实例上的选项,但我真正想要的是设置一些php.ini或类似的地方,将处理这一点在所有的项目和所有实例。

I understand that I can set the option on any specific instance, however what I would really like is to set something up php.ini or somewhere similar which will handle this across all projects and all instances.

有没有人知道一个方法来完成这个?

Does anyone know a way for me to accomplish this?

编辑:
我特别感兴趣的解决方案允许证书在不同的服务器上的不同位置。

I am particularly interested in a solution which will allow for the certificates to be in different locations on different servers.

我在一个Windows机器上开发,需要这个,但是部署到一个Linux服务器,不仅不会需要它,但是没有指明的路径。

I am developing on a Windows machine which needs this but deploying to a Linux server which not only doesn't need it but doesn't even have the path indicated.

我知道我可以使用条件来检查代码运行,但希望只是它的工作的盒子。在我看来,这真的是一个问题,curl和PHP处理而不是我的代码,因此它的设置属于那里。

I understand that I can use conditions to check where the code is running but would prefer to just have it work out of the box. It seems to me that this is really an issue for curl and PHP to handle rather than my code and hence the settings for it belong there.

推荐答案

我在这里找到了答案(在用户注释中): http://php.net/ manual / en / function.curl-setopt.php

I found the answer here (in the user notes): http://php.net/manual/en/function.curl-setopt.php

只需将它添加到.ini(注意:不能使用 ini_set ,虽然我不知道你为什么要。)感谢@Carlton):

Just add this to you .ini (note: you cannot use ini_set, although I don't know why you would want to. Thanks @Carlton):

curl.cainfo=c:\php\cacert.pem

href =http://curl.haxx.se/docs/caextract.html> http://curl.haxx.se/docs/caextract.html

And get that file from: http://curl.haxx.se/docs/caextract.html

工作,你不打开自己的MITM攻击

Works and you aren't opening yourself up for MITM attacks

这篇关于如何在Windows上为PHP全局设置CURLOPT_CAINFO?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆