php-stream_context_create函数针对https请求处理

官方文档有很多例子
https://www.php.net/manual/zh/function.stream-context-create.php
但是有些旧了
当我在源码编译安装php的时候, 有脚本使用了这个函数进行https的时候报错了

Warning: fopen(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP? in /mnt/software/php-src/pear/fetch.php on line 66

Warning: fopen(https://pear.php.net/install-pear-nozlib.phar): failed to open stream: No such file or directory in /mnt/software/php-src/pear/fetch.php on line 66`

当我查看php-src/pear/fetch.php脚本时,代码是这样的:
php-stream_context_create函数针对https请求处理

并没有https请求对安全认证做处理,导致无法访问链接
*找了这个在请求头设置关闭证书的校验:
https://*.com/questions/45273206/https-for-stream-context-create
php-stream_context_create函数针对https请求处理

    $copt = array(
        'http' => array(
            'proxy' => preg_replace('/^http/i', 'tcp', $_ENV['http_proxy']),
            'request_fulluri' => true,
        ),
        'ssl'  => [ // here comes the actual SSL part...
            'verify_peer'      => false,
            'verify_peer_name' => false,
        ]
    );

php-stream_context_create函数针对https请求处理

重新编译安装成功!

php-stream_context_create函数针对https请求处理
丝滑.....

上一篇:【APUE学习笔记】第三章 文件I/O


下一篇:DAY006-CSS基础