我已经安装了WAMP 3.0.4,并且正在尝试编写连接到外部HTTPS Web服务的PHP脚本。但是,这将返回错误:file_get_contents():SSL操作失败,代码为1(证书验证失败)
Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
我写了证明的问题很短的脚本:
<?php
$auth = base64_encode('username:password');
$aContext = array(
'http' => array(
'proxy' => 'tcp://proxyip:proxyport',
'request_fulluri' => true,
'header' => 'Proxy-Authorization: Basic $auth'
),
'SSL' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true,
'cafile' => 'C:/wamp/certificates/cacert.pem'
)
);
$cxContext = stream_context_create($aContext);
$sFile = file_get_contents("https://www.google.com", False, $cxContext);
echo $sFile;
?>
它是使用代理服务器的要求。
可以看出,我已经尝试安装根证书包,并且还将verify_peer添加到false(不是我会在生产中这样做),但仍然收到此错误。
从上面可以清楚地看出,我是Apache/WAMP新手。有人可能可以解释我失踪了吗?
感谢您花时间回复。不幸的是,我已经尝试了这些东西,仍然收到错误。我编辑了这个问题,试图使这个更清楚。 – BrightonBoy