我有一个具有2个域的在线服务器,均由letsencrypt进行SSL认证
在域A上,我创建了一个包含json内容的文件,可以使用此代码从我的PC读取
MyClass.java
当我将文件上传到domainB时,我得到了
$url = 'https://www.domainA.com/feed.php';
$response = file_get_contents($url, true);
$obj = json_decode($response, true);
print_r($obj);
编辑
此代码存在相同的问题
Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in ...
Warning: file_get_contents(): Failed to enable crypto in ...
Warning: file_get_contents(https://www.domainA.com/feed.php): failed to open stream: operation failed in ...
响应为
$url = 'https://www.domainA.com/feed.php';
$arrContextOptions=array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
$result = file_get_contents($url, false, stream_context_create($arrContextOptions));
还有此CURL代码
failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in ...
我有
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$result = curl_exec($ch);
curl_close($ch);
print_r($result);
$obj = json_decode($result, true);
print_r($obj);