我一直在尝试从我在服务器上创建的PHP页面访问这个特定的REST服务.我将问题缩小到这两行.所以我的PHP页面如下所示:
<?php
$response = file_get_contents("https://maps.co.weber.ut.us/arcgis/rest/services/SDE_composite_locator/GeocodeServer/findAddressCandidates?Street=&SingleLine=3042+N+1050+W&outFields=*&outSR=102100&searchExtent=&f=json");
echo $response; ?>
Run Code Online (Sandbox Code Playgroud)
该页面在第2行死亡,并出现以下错误:
- 警告:file_get_contents():SSL操作失败,代码为1. OpenSSL错误消息:错误:14090086:SSL例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败...第2行的php
- 警告:file_get_contents():无法在第2行的... php中启用加密
- 警告:file_get_contents(
https://maps.co.weber.ut.us/arcgis/rest/services/SDE_composite_locator/GeocodeServer/findAddressCandidates?Street=&SingleLine=3042+N+1050+W&outFields=*&outSR=102100&searchExtent=&f=json):无法打开流:第2行的... php操作失败
我们正在使用Gentoo服务器.我们最近升级到PHP 5.6版.升级后出现此问题.
我发现,当我一个地址替换REST服务一样https://www.google.com; 我的页面工作正常.
在我之前的一次尝试中,我将“verify_peer”=>false其作为参数传递给file_get_contents,如下所述: file_get_contents忽略verify_peer => false? 但就像作者所指出的那样; 它没有任何区别.
我问过我们的服务器管理员是否存在php.ini文件中的这些行:
他告诉我,因为我们在Gentoo上,openssl是在我们构建时编译的; 并且它没有在php.ini文件中设置.
我也证实这allow_url_fopen是有效的.由于这个问题的专业性; 我没有找到很多帮助信息.有没有人遇到过这样的事情?谢谢.
我正在设置信用卡处理,需要使用CURL的解决方法.当我使用测试服务器(没有调用SSL URL)时,以下代码工作正常,但现在当我在使用HTTPS的工作服务器上测试它时,它失败并显示错误消息"无法打开流".
function send($packet, $url) {
$ctx = stream_context_create(
array(
'http'=>array(
'header'=>"Content-type: application/x-www-form-urlencoded",
'method'=>'POST',
'content'=>$packet
)
)
);
return file_get_contents($url, 0, $ctx);
}
Run Code Online (Sandbox Code Playgroud) 我正在使用key,ca,cert in options测试对本地节点服务器的SSL访问(自签名w OpenSSL)
var server_options = {
key: fs.readFileSync('/etc/ssl/self-signed/server.key'),
ca: fs.readFileSync('/etc/ssl/self-signed/server.csr'),
cert: fs.readFileSync('/etc/ssl/self-signed/server.crt')
};
Run Code Online (Sandbox Code Playgroud)
试图访问它:
curl -v --user 1234567890:abcdefghijklmnopqrstuvwxyz --data "grant_type=password&username=yves&password=123456789" https://macMini.local:8000/oauth/token
Run Code Online (Sandbox Code Playgroud)
使用curl我收到以下错误:
curl:(60)SSL证书问题,验证CA证书是否正常.详细信息:错误:14090086:SSL例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败
我从http://curl.haxx.se/ca/cacert.pem下载了ca证书并将它们添加到我的curl-ca-bundle-new.crt文件中,正如一些与curl相关的帖子中所建议的那样...但是没有办法
这是日志
- 即将connect()连接到macMini.local端口8000(#0)
- 试试192.168.1.14 ......
- 连接的
- 连接到macMini.local(192.168.1.14)端口8000(#0)
- SSLv3,TLS握手,客户端问候(1):
- SSLv3,TLS握手,服务器问候(2):
- SSLv3,TLS握手,CERT(11):
- SSLv3,TLS警报,服务器问候(2):
- SSL证书问题,验证CA证书是否正常.详细信息:错误:14090086:SSL例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败
- 关闭连接#0 curl:(60)SSL证书问题,验证CA证书是否正常.详细信息:错误:14090086:SSL例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败更多详细信息,请访问:http://curl.haxx.se/docs/sslcerts.html
我知道我可以绕过Curl CA检查,使用:
curl -k -v --user 1234567890:abcdefghijklmnopqrstuvwxyz --data "grant_type=password&username=yves&password=123456789" https://macMini.local:8000/oauth/token
Run Code Online (Sandbox Code Playgroud)
在这种情况下运行正常,我可以看到:
SSL证书验证结果:自签名证书(18),无论如何都要继续.
但我想知道是否有办法解决这个问题......
当我尝试从谷歌获取图像并且它为单次搜索提供4个图像时,由于图像大小,我无法获得一些图像.所以我得到的错误就像
"file_get_contents():无法启用加密"
有什么解决方案吗?这是我的代码
<?php
use frontend\models\Giftinterests;
use yii\amazonproductapi\AmazonProductAPI;
use yii\helpers\Url;
use yii\web\NotFoundHttpException;
use yii\image\ImageDriver;
$sql_1 = 'SELECT * FROM `tn_gift_interests` where `gift_interest_status`="1" order by `gift_interest_id` ASC';
$Query_Gift = Giftinterests::findBySql($sql_1)->all();
$sql_2="TRUNCATE `tn_gift_google_image`";
$query_1 = Yii::$app->db->createCommand($sql_2)->execute();
function get_url_contents($url) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_USERAGENT, 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)');
curl_setopt($crl, CURLOPT_URL, $url);
curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($crl, CURLOPT_SSLVERSION,3);
curl_setopt($crl, CURLOPT_SSL_VERIFYPEER, true);
$ret = curl_exec($crl);
curl_close($crl);
return $ret;
}
$width=260;$height=229;
$a=0;
foreach($Query_Gift as $two):
$a++;
$amazon …Run Code Online (Sandbox Code Playgroud) 我正在使用OS X Yosemite
我在Composer中运行以下命令,因为Laravel无法始终正常下载和安装:
composer diagnose
结果:
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: FAIL
[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Failed to enable crypto
failed to open stream: operation failed
Checking github.com rate limit: FAIL
[Composer\Downloader\TransportException] The "https://api.github.com/rate_limit" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages: …Run Code Online (Sandbox Code Playgroud)