file_get_contents ignoring verify_peer=>false?

前端 未结 5 757
遇见更好的自我
遇见更好的自我 2020-12-16 16:14

file_get_contents with https hosts works just fine, except for a particular host (test api server from some company - ip whitelisted, can\'t give you URL to test). This rule

5条回答
  •  执笔经年
    2020-12-16 16:41

    You missed verify_peer_name. If you set that to false as well, the request works:

    $arrContextOptions=array(
        "http" => array(
            "method" => "POST",
            "header" => 
                "Content-Type: application/xml; charset=utf-8;\r\n".
                "Connection: close\r\n",
            "ignore_errors" => true,
            "timeout" => (float)30.0,
            "content" => $strRequestXML,
        ),
        "ssl"=>array(
            "allow_self_signed"=>true,
            "verify_peer"=>false,
            "verify_peer_name"=>false,
        ),
    );
    
    file_get_contents("https://somedomain:2000/abc/", false, stream_context_create($arrContextOptions));
    

提交回复
热议问题