dsgffz2579 2014-08-20 15:04
浏览 31
已采纳

请求未经验证的网站

I am trying to use PHP's curl() function and for some reason my code does not return any data.

I am making a request to a URL that is unverified:

enter image description here

Here is my code:

<?php
$ch = curl_init("**SENSITIVE URL**");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
print_r($result);

curl_close($ch);
?>

If I put in www.google.com it does return the google webpage to my site. I apoligize, but I can't give out the URL for my site but I assure you that directly going to the URL does return data.

  • 写回答

1条回答 默认 最新

  • dsa5211314 2014-08-20 15:15
    关注

    You need to tell cURL to ignore the (bad) SSL cert. Try adding the following options:

    // Do not verify the cert
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    // Ignore the "does not match target host name" error
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 已知许多点位,想通过高斯分布来随机选择固定数量的点位怎么改
  • ¥15 怎么生成确定数目的泊松点过程
  • ¥15 layui数据表格多次重载的数据覆盖问题
  • ¥15 python点云生成mesh精度不够怎么办
  • ¥15 QT C++ 鼠标键盘通信
  • ¥15 改进Yolov8时添加的注意力模块在task.py里检测不到
  • ¥50 高维数据处理方法求指导
  • ¥100 数字取证课程 关于FAT文件系统的操作
  • ¥15 如何使用js实现打印时每页设置统一的标题
  • ¥15 安装TIA PortalV15.1报错