get_headers():SSL操作失败,代码为1

时间:2016-05-17 11:00:21

标签: php

嘿,我试图获取网址的标题信息,

当我使用协议http它工作正常,但当我使用https时,它无法正常工作

网址:https://200.35.78.130/

print_r(get_headers("https://200.35.78.130/", 1));

这是我的代码

{{1}}

2 个答案:

答案 0 :(得分:17)

That error occurs when you're trying to access a URL without a valid SSL certificate. You can work around this by overriding the default stream context, which will affect all subsequent file operations (including remote URLs)

<?php
stream_context_set_default( [
    'ssl' => [
        'verify_peer' => false,
        'verify_peer_name' => false,
    ],
]);

print_r(get_headers('https://200.35.78.130/'));

答案 1 :(得分:-2)

因为您安装的SSL证书没有中间密钥