我一直在尝试从我在服务器上创建的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是有效的.由于这个问题的专业性; 我没有找到很多帮助信息.有没有人遇到过这样的事情?谢谢.
我在几个项目中使用过PHPMailer,但现在我卡住了.它给我错误:
SMTP错误:无法连接到SMTP主机.
我试过从Thunderbird发送电子邮件,它确实有效!但不是通过PHPMailer ......以下是Thunderbird的设置:
服务器名称:mail.exampleserver.com
端口:587
用户名:user@exampleserver.com
安全身份验证:无
连接安全性:STARTTLS
我在上一个使用PHPMailer的项目中将这些与服务器进行了比较,它们是:
服务器名称:mail.exampleserver2.com
端口:465
用户名:user@exampleserver2.com
安全认证:无
连接安全性:SSL/TLS
我的PHP代码是:
$mail = new PHPMailer();
$mail->IsSMTP(); // send via SMTP
$mail->Host = SMTP_HOST; // SMTP servers
$mail->Port = SMTP_PORT; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = SMTP_USER; // SMTP username
$mail->Password = SMTP_PASSWORD; // SMTP password
$mail->From = MAIL_SYSTEM;
$mail->FromName = MAIL_SYSTEM_NAME;
$mail->AddAddress($aSecuredGetRequest['email']);
$mail->IsHTML(true); // send as HTML
Run Code Online (Sandbox Code Playgroud)
哪里错了?
一两天后,我的旧 php 容器 (dockerhub php:5.4-apache) 无法再使用curl。这是在此容器内运行curl 时的日志。
$> docker run --rm -ti php:5.6-apache bash
$> curl -X POST https://xxxxx.com
curl: (60) SSL certificate problem: certificate has expired
More details here: https://curl.haxx.se/docs/sslcerts.html
curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the …Run Code Online (Sandbox Code Playgroud)