Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
596 views
in Technique[技术] by (71.8m points)

ssl - How can I set CURLOPT_CAINFO globally for PHP?

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?

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

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.

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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:phpcacert.pem

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...