PHP - curlopt_ssl_verifypeer false不起作用

时间:2017-11-03 12:13:19

标签: php ssl curl

执行此操作时:

$ch = curl_init();
curl_setopt($ch, curlOPT_URL, "https://www.extern.com/extern/v/fragebogenweg.php?file=412954715521130");
curl_setopt($ch, curlOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, curlOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, curlOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);

https://www.extern.com/extern/v/fragebogenweg.php

$requestfrom = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);

if($requestfrom == 'www.bla.com')
{
    header("Access-Control-Allow-Origin: https://www.bla.com");
}
elseif($requestfrom == 'bla.com')
{
    header("Access-Control-Allow-Origin: https://bla.com");
}

unlink('fragebogen/' . $_GET['file'] . '.json');

它没有用,它在SSL安装之前有效但现在不再是我添加的原因了

curl_setopt($ch, curlOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, curlOPT_SSL_VERIFYPEER, false);

但它没有帮助

更新

我在Chrome控制台中得到了这个:

A bad HTTP response code (404) was received when fetching the script.
service-worker.js Failed to load resource: net::ERR_INVALID_RESPONSE

1 个答案:

答案 0 :(得分:0)

常量中有拼写错误:

  • CURLOPT_URL
  • CURLOPT_SSL_VERIFYHOST
  • CURLOPT_SSL_VERIFYPEER
  • curlOPT_HEADER

似乎区分大小写;试试这个:

string instrumentationKey = Environment.GetEnvironmentVariable("APPINSIGHTS_INSTRUMENTATIONKEY");
if (!string.IsNullOrEmpty(instrumentationKey))
{
      // build up a LoggerFactory with ApplicationInsights and a Console Logger
       config.LoggerFactory = new LoggerFactory().AddApplicationInsights(instrumentationKey, null).AddConsole();
       config.Tracing.ConsoleLevel = TraceLevel.Off;
}