Web Hosting
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: Error: WordPress could not establish a secure connection to...

Discussion in 'Misc WordPress Requests' started by Samuel Wood (Otto), Nov 19, 2017.

  1. Samuel Wood (Otto)

    Guest

    Reply To: Error: WordPress could not establish a secure connection to WordPress.org, by Samuel Wood (Otto)

    You should probably use a more future proof way, rather than altering the core files.

    Something like this should do the trick (untested):


    add_action('http_api_curl', 'custom_curl_resolve', 10, 3 );
    function custom_curl_resolve( $handle, $r, $url ) {
    curl_setopt($handle, CURLOPT_RESOLVE, array(
    "api.wordpress.org:80:66.155.40.187",
    "api.wordpress.org:443:66.155.40.187",
    "downloads.wordpress.org:80:66.155.40.203",
    "downloads.wordpress.org:443:66.155.40.203")
    );
    }


    You could add on to this, if you like, and add logic to check the $url to see if it matches one of those and then you’d only be adding the ones you need.

    The http_api_curl happens before the request to curl_exec is fired, and curl is already init’d by that point, so much of the rest of the code that sets options you have could be added there if those are needed.

    This code could be contained in a plugin or in a mu-plugin and would survive upgrades.

    Edit: Note that the http_api_curl hook is there for backwards compatibility. If you want to use the same hook but specific to the Requests system, that hook is requests-curl.before_send.

    Reply To: Error: WordPress could not establish a secure connection to WordPress.org
     
    #1

Share This Page

Web Hosting