Woocommerce errors on creating REST API KEYS


Ref to https://woocommerce.github.io/woocommerce-rest-api-docs/#rest-api-keys you create a url that should return you to your site/application when you create a Rest api key.

But i got the next 2 messages when wish to connect my php app to woocommerce in local development environment and using self signed certificate.

Error: A valid URL was not provided..


Error: cURL error 60: SSL certificate problem: self signed certificate.

both come from different places. I resolved my problem with the first message by adding this code in functions.php in theme:

function turn_off_reject_unsafe_urls($args) {
$args['reject_unsafe_urls'] = false;
return $args;
add_filter( 'http_request_args', 'turn_off_reject_unsafe_urls');

and second by adding:

add_action('http_api_curl', function( $handle ){
//Don't verify SSL certs
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);

// //Use Charles HTTP Proxy
// curl_setopt($handle, CURLOPT_PROXY, "");
// curl_setopt($handle, CURLOPT_PROXYPORT, 8888);
}, 10);

i hope this will help you.

Don’t use this code on live server. Code is only for local/localhost development and you have a problem with Self signed certificate

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll Up