doutan1637 2019-01-18 13:21
浏览 139

stream_context_create不再使用SSL / HTTPS和代理

I have a php script that sends details to an external HTTPS site through our proxy and returns a json file. It's been working fine until a few days ago where it now returns an error

After reading various posts on here, I've tried adding https instead of http in the context options, but I still get the same error. If I change the site to something like https://google.com it's fine. Visiting the URL in a browser also works fine and returns the JSON file as expected, and we use the same proxy for browsing that's specified in the PHP.

<?php
$arrContextOptions=array(
    'http' => array(
        'proxy' => 'servername:8080',
        'request_fulluri' => true,
    )
);
$sortCode = $_POST['sortCode'];
$accNum = $_POST['accNum'];
$fullURL = "https://websiteURL.com/api/textremoved?apikey=ABCDEF1234&sortCode=".$sortCode."&accountNumber=".$accNum;
$json = file_get_contents($fullURL, false, stream_context_create($arrContextOptions));
$obj = json_decode($json);
?>

The errors I get are:

PHP Warning:  file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure in C:\inetpub\wwwroot\Finance\DirectDebit.php on line 42

PHP Warning:  file_get_contents(https://websiteURL.com/api/textremoved?apikey=ABCDEF1234&sortCode=123456&accountNumber=12345678): failed to open stream: Cannot connect to HTTPS server through proxy in C:\inetpub\wwwroot\Finance\DirectDebit.php on line 42

Line 42 in the full file (have removed CSS etc) is:

$json = file_get_contents($fullURL, false, stream_context_create($arrContextOptions));

A couple of days ago when it was working, there were no errors, it just returned the JSON

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 树莓派与pix飞控通信
    • ¥15 自动转发微信群信息到另外一个微信群
    • ¥15 outlook无法配置成功
    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题