wordpress-google-cse icon indicating copy to clipboard operation
wordpress-google-cse copied to clipboard

ERROR: SSL: CA certificate set, but certificate verification is disabled

Open bjornbjorn opened this issue 10 years ago • 1 comments
trafficstars

Hi,

after installing the plugin and saving the API Key and Search Engine ID in settings I get the following error message:

ERROR: SSL: CA certificate set, but certificate verification is disabled

bjornbjorn avatar Mar 30 '15 11:03 bjornbjorn

Found the reason for this, on line 83 in google-cse.php:

        // Request response
        if(is_wp_error($response = wp_remote_get($url, array('sslverify' => false)))) {
            return array('error' => array('errors' =>
                array(array('reason' => $response->get_error_message()))));
        }

sslverify is set to false, yet the latest version of WordPress ships a list of trused certificate roots with the request, so this throws the error.

I imagine earlier versions of WP would not ship a certificate, and thus it would work and/or earlier versions of curl wouldn't throw an error when shipping a certificate + verifyssl=false, however now it does ..

So, to "fix" set sslverify to true:

        // Request response
        if(is_wp_error($response = wp_remote_get($url, array('sslverify' => true)))) {
            return array('error' => array('errors' =>
                array(array('reason' => $response->get_error_message()))));
        }

Probably best to check WP version though to make it backward compatible.

bjornbjorn avatar Mar 30 '15 14:03 bjornbjorn