站点使用cloudflare时无法连接api

分享于2022年07月17日 cloudflare php 问答
【问题标题】:站点使用cloudflare时无法连接api(Cannot connect to the api when the site uses cloudflare)
【发布时间】:2022-07-11 20:31:10
【问题描述】:

我有一个也提供 api 的服务站点。

但是我的站点用户不能使用api,因为站点连接到cloudflare!

我通过 file_get_contents 连接到我的网站,但出现错误

这意味着我将 mywebsite.com/test.php 连接到 mywebsite.com/api/v2 ...

我收到了这个错误:

Warning: file_get_contents(): Peer certificate CN=`amazeservice.net' did not match expected CN=`mywebsite.com' in /home/mywebsite/public_html/test.php on line 3

Warning: file_get_contents(): Failed to enable crypto in /home/mywebsite/public_html/test.php on line 3

Warning: file_get_contents(https://mywebsite.com/api/v2): failed to open stream: operation failed in /home/mywebsite/public_html/test.php on line 3

我试图在我的 cloudflare 论坛中提出这个问题,但我不知道为什么无法发布问题。

  • 您在客户端使用的是什么版本的 PHP 和 OpenSSL?

【解决方案1】:

现在,Cloudflare API 安全产品仅供企业客户使用。

https://developers.cloudflare.com/api-shield/