douqipi9704 2009-09-30 16:23
浏览 18
已采纳

使用cURL加载安全文件

I'm trying to use cURL to access a secure file.. The documentation for its use is confusing so I searched and found two sites (1 & 2) and a reference here on SO but the scripts don't seem to work for me.

The site I'm am trying to access has the data I need publicly available, so I don't need to log in or provide a password.

This is the script I have and all it does is sit there waiting for something to happen (I get no errors).

$ch = curl_init('https://www.somesite.com/index.htm');

curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);

// Disable PEER SSL Verification: If you are not running with SSL or if you don't have valid SSL
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

// Disable HOST (the site you are sending request to) SSL Verification,
// if Host can have certificate which is nvalid / expired / not signed by authorized CA.
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);

$sFile = curl_exec($ch);
curl_close($ch);

I just need to figure out what I'm doing wrong here. Thanks!

Update: The script does work locally in XAMPP, but not on the live server (am I missing a php setting? - probably something I can't touch because I'm using a free hosting service, for now). I also found this article about grabbing a certificate, but it isn't clear to me if I need to grab the one from delicious or the site I'm trying to access.

  • 写回答

2条回答 默认 最新

  • douniewei6346 2009-10-01 07:25
    关注

    try something like

    $sFile = curl_exec($ch);
    $info = curl_getinfo($ch);
    
    print_r($info);
    

    that should contain some useful information.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比
  • ¥15 winform的chart曲线生成时有凸起
  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作