Categories
WordPress

Error: WordPress could not establish a secure connection

So as you can see, I have recently re-setup my blog.

Everything seemed to go smoothly up until I tried installing a theme (either directly or via file-upload), whereupon I would receive the same error message every time:

Error: WordPress could not establish a secure connection to WordPress.org

I wasted a couple of hours upgrading PHP, CURL, OpenSSL as well as my the OpenSSL root before stumbling upon https://wordpress.org/support/topic/error-wordpress-could-not-establish-a-secure-connection-to-wordpress-org/

This user had exactly the same problem, which he traced to an incompatibility between Curl and SSL with regards to IPV6.
Following his advice, I added just before the end of __construct in wp-includes/Requests/Transport/cURL.php the following line:

curl_setopt($this->handle, CURLOPT_RESOLVE, array("api.wordpress.org:80:198.143.164.251", "api.wordpress.org:443:198.143.164.251"));

It’s an absolute terrible hack (hard coded IP addresses what could possibly go wrong!) but at least I can install themes on this blog now. So many thanks PeterBB, and eagerly awaiting a resolution to https://meta.trac.wordpress.org/ticket/3090