I’ve got a simple php script which is connecting to my wordpress to create a product. Using the woocommerce rest api library.
$woocommerce = new Client(
'https://dev.example.co.uk',
'123456789',
'123456789',
[
'wp_api' => true,
'version' => 'wc/v3',
'sslverify' => false,
]
);
// foreach item
$woocommerce->post( 'products', $data );
Fatal error: Uncaught Automattic\WooCommerce\HttpClient\HttpClientException: cURL Error: SSL certificate problem: self signed certificate in /srv/www/example.co.uk/current/web/app/themes/exampletheme/vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php on line 417
I’ve attempted the following:
Get the certificate from the dev site:
openssl s_client -connect example.co.uk:443 | tee logfile
Copied the certificate and made a file from it called certificate.crt
MIICyTCCAbGgAwIBAgIJANB2....
Uploaded to:
/srv/www/example.co.uk/current/web/wp/certificate.crt
And now trying to use it to prevent this error.
functions.php
add_action( 'http_api_curl', function( $handle ) {
curl_setopt($handle, CURLOPT_CAINFO, ABSPATH . 'certificate.crt');
});
// the value of ABSPATH is: /srv/www/example.co.uk/current/web/wp/
Same error remains. Can’t tell if the custom cert is being used or not too. If it is then something else must be wrong maybe.