【问题标题】:Google recaptcha not working on server, but working on localhostGoogle recaptcha 不在服务器上工作,但在 localhost 上工作
【发布时间】:2019-08-13 14:53:11
【问题描述】:

我想使用 curl 访问 googles recaptcha v2 api,但它只能在我的本地主机上运行。错误是“SSL 对等证书或 SSH 远程密钥不正常”。当我设法绕过时这给了我一个 301 Moved Permanently 错误,导致 404 错误curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); 没有解决这个问题。另一个奇怪的事情是 namelookup_time 超过 15 秒,也就是真的很慢。

我尝试禁用 CURLOPT_SSL_VERIFYPEER 和 CURLOPT_SSL_VERIFYHOST ,添加 cacert.pem 文件和所有其他 CA 捆绑包,但它仍然不起作用。问题显然与 SSL 证书有关,但我已经尝试了互联网上的所有内容。另一件有用的事情可能是说在我的服务器上 curl 有点旧,以及其他所有内容。

$url = "https://www.google.com/recaptcha/api/siteverify";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER,array("Content-type: application/json; charset=utf-8"));
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
url_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => 1
CURLOPT_POSTFIELDS => array(
        'secret' => $mysecret,
        'response' => $mycaptcha,
    )

【问题讨论】:

  • 是的,我知道,这就是为什么我说我下载并添加了证书包。

标签: php curl libcurl


【解决方案1】:

问题在于服务器的绑定。它滞后了,这导致了缓慢和不可能的连接,重新启动后一切正常。希望这会对某人有所帮助!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多