[英]Can't seem to get CURLOPT_SSL_VERIFYPEER to behave in PHP
Ultimately, I'm trying to set up a simple site with links that initiate a cURL POST using basic auth. 最终,我试图通过链接建立一个简单的站点,该链接使用基本身份验证启动cURL POST。 The href of the link points to blah.php?dothething
. 链接的href指向blah.php?dothething
。
In the php file, I have 在php文件中,我有
if ($_SERVER['QUERY_STRING'] == 'dothething') {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://blah/");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "thing=1&do=true");
curl_setopt($ch, CURLOPT_USERPWD, "user:pwd");
curl_setopt($ch, CURLOPT_PIPEWAIT, TRUE); //POST takes about 10 sec to process
curl_setopt($ch, CURLOPT_SSLVERIFYPEER, FALSE); //self-signed cert
curl_exec($ch);
curl_close($ch);
}
When I visit the link, I get: 当我访问链接时,我得到:
Warning : curl_setopt() expects parameter 2 to be integer, string given in blah.php on line 31 警告 :curl_setopt()期望参数2为整数,第31行的blah.php中给出的字符串
Warning : curl_setopt() expects parameter 2 to be integer, string given in blah.php on line 32 警告 :curl_setopt()期望参数2为整数,第32行的blah.php中给出的字符串
I've tried TRUE
, true
, "true"
, and 1
, and have gotten the same error every time. 我已经尝试过TRUE
, true
, "true"
和1
,并且每次都遇到相同的错误。
I'm running this on PHP v7.0.14 on DreamHost. 我正在DreamHost的PHP v7.0.14上运行它。 Looks like these options have been available since v7.0.7, are they maybe just not available in DreamHost's PHP? 这些选项似乎自v7.0.7起可用,它们可能只是在DreamHost的PHP中不可用? If that's the case, is there any way to not validate the cert, other than running it somewhere else? 如果是这样,除了在其他地方运行该证书之外,是否有其他方法可以不验证该证书?
You're missing an underscore: 您缺少下划线:
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
Or even better, just go to https://letsencrypt.org/ and get yourself a real cert for free. 甚至更好的是,只需访问https://letsencrypt.org/并免费获得真实证书。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.