我正在尝试使用file_get_contents阅读提供一些JSON对象的远程网站。连接应该加密,所以我尝试使用HTTPS连接。
<?php
$arrContextOptions=array(
"ssl"=>array(
"cafile" => "api.crt",
"verify_peer"=> true,
"verify_peer_name"=> true
),
);
$context = stream_context_create($arrContextOptions);
$jsonObjects = file_get_contents('https://example.com', false, $context);
?>
但是,连接失败并出现以下错误:
PHP Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:14077458:SSL routines:SSL23_GET_SERVER_HELLO:reason(1112) in api-read.php on line 13
PHP Warning: file_get_contents(): Failed to enable crypto in api-read.php on line 13
PHP Warning: file_get_contents(https://example.com): failed to open stream: operation failed in api-read.php on line 13
到目前为止我发现的消息来源提到了不同的可能原因。
到目前为止,我无法解决问题或找到任何有用的信息。我的想法已经不多了。有什么建议吗?