php get_headers 报错 get_headers(): SSL operation failed with code 1. OpenSSL Error messages

saonian 发布于 18-08-16 13:12 926 点击
使用 `get_headers` 函数获取请求头时,报了下面的错。 ``` get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in ``` 这是因为你访问的URL没有有效的ssl证书 > 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) **解决办法** 在get_headers前增加下面的代码 ```php stream_context_set_default( [ 'ssl' => [ 'verify_peer' => false, 'verify_peer_name' => false, ], ]); $headers = get_headers($httpPath, 1); ```
0 评论

请登录后发表评论

saonian

all or nothing, now or never.

文章
回复
粉丝