You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PHP站点调用reCAPTCHA API遇cURL error 60问题求助

Fixing cURL Error 60 with reCAPTCHA in PHP

Hey there, let's work through this frustrating cURL error 60 issue together! You've already tried the basic fix of adding the CA certificate to php.ini, so let's dive into the less obvious checks that might be causing the problem.

Common Troubleshooting Steps to Try

  • Verify you're editing the correct php.ini file
    It's super easy to modify the wrong configuration file—PHP often uses different php.ini files for CLI and web server requests. Create a quick test file with:

    <?php phpinfo(); ?>
    

    Access it in your browser, then look for the Loaded Configuration File line. Make sure the php.ini you edited matches this path.

  • Double-check the curl.cainfo absolute path
    Ensure the path you entered is a full, valid absolute path (no truncated entries like /var/w...). For example:

    [curl]
    curl.cainfo="/var/www/html/cacert.pem"
    

    Also, confirm the web server user (like www-data for Apache or nginx for Nginx) has read permissions on the .pem file. Fix permissions with:

    chmod 644 /var/www/html/cacert.pem
    chown www-data:www-data /var/www/html/cacert.pem
    
  • Restart your web server (and PHP-FPM if using it)
    Changes to php.ini won't take effect until you restart your web server. For Apache:

    sudo systemctl restart apache2
    

    If you're using Nginx with PHP-FPM, restart both services:

    sudo systemctl restart nginx
    sudo systemctl restart php8.2-fpm # Replace with your PHP version
    
  • Test with manual CA certificate setup in code
    To rule out php.ini configuration issues, directly set the CA cert path in your reCAPTCHA cURL call:

    $ch = curl_init("https://www.google.com/recaptcha/api/siteverify");
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, [
        'secret' => 'YOUR_RECAPTCHA_SECRET',
        'response' => $_POST['g-recaptcha-response']
    ]);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_CAINFO, "/var/www/html/cacert.pem"); // Full path to your .pem
    $response = curl_exec($ch);
    $error = curl_error($ch);
    curl_close($ch);
    
    if ($error) {
        echo "cURL Error: " . $error;
    } else {
        // Process reCAPTCHA response
    }
    

    If this works, it means your php.ini changes aren't being picked up—go back to verifying the correct file path and restarting services.

  • Update system-level CA certificates
    Sometimes system-wide CA certs are outdated. On Ubuntu/Debian:

    sudo apt-get update && sudo apt-get install --reinstall ca-certificates
    

    On CentOS/RHEL:

    sudo yum reinstall ca-certificates
    

    Restart your web server after updating.

  • Confirm reCAPTCHA API URL is correct
    Ensure you're calling the valid HTTPS endpoint: https://www.google.com/recaptcha/api/siteverify (this works for both v2 and v3 reCAPTCHA). Typos here can also trigger SSL errors.

Give these steps a shot—one of them is almost certainly the fix you need. Let me know if you hit any snags along the way!

内容的提问来源于stack exchange,提问作者Freddy Heppell

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 07:27:24