"Error: cURL error 60: SSL certificate problem: certificate has expired" when create product in WooCommerce via REST API

Everything worked fine a week ago. Lets Encrypt certificate on the site is valid. I am currently getting the following error while creating a product:

{code:woocommerce_product_image_upload_error,message:Error getting remote image https:\/\/mysite.com\/wp-content\/uploads\/2021\/10\/60c739fd1-1.jpg. Error: cURL error 60: SSL certificate problem: certificate has expired,data:{status:400}}

In this case, the picture is available by the URL. Tried these solutions (https://wp-kama.com/note/error-making-request-wordpress[enter link description here]1) but doesn't help.

Topic rest-api ssl Wordpress

Category Web


This is a one liner, that can be added to a Dockerfile with RUN or just ran in the terminal

# Fix Outdate Let's Encrypt cert
curl --silent --insecure https://letsencrypt.org/certs/isrgrootx1.pem >> /usr/local/share/ca-certificates/isrgrootx1.pem && \
    sed -i 's=mozilla/DST_Root_CA_X3.crt=!mozilla/DST_Root_CA_X3.crt=g' /etc/ca-certificates.conf && \
    update-ca-certificate

It pulls down the latest cert insecurely so carries risk.

This didn't resolve the problem for me because PHP was using a different trust store from the systemwide one.

Our apache2 instance which is running PHP was in a Docker container. The trust store needed to be updated with a script just before the start of apache2, because it was created at runtime overwriting any changes made before execution.

Setting the path to true should use the system trust store rather than a custom bundle.

# Pull updated CA cert bundle
CERT_PATH=/var/www/html/wp-includes/certificates
mkdir -p $CERT_PATH && curl --silent https://curl.se/ca/cacert.pem > $CERT_PATH/ca-bundle.crt 

In the file /etc/ca-certificates.conf, you need to find the line:

mozilla / DST_Root_CA_X3.crt

and put the "!" symbol at the beginning of the dates:

! mozilla / DST_Root_CA_X3.crt

Next, you need to run the command:

sudo update-ca-certificates

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.