5

I have a multi-wordpress installation (3.x) with 5 sites and only one of them is using SSL.

All of these are running on their own domain, and the http://ssldomain.com forwards to https://ssldomain.com.

Still, this seems to break wordpress upgrades.

Now I get a message:

Upgrade Network

https://nonsecureddomain.com

Warning! Problem updating https://nonsecureddomain.com. Your server may not be able to connect to sites running on it. Error message: SSL: no alternative certificate subject name matches target host name 'nonsecureddomain.com'

It seems that at some point WP decides to go HTTPS for this domain, where it is not supposed to.

The network itself is the one running on HTTPS(SSL), and what concerns me is that

https://mydecureddomain.com/wp-admin/network/site-info.php?id=5

Is listing the site with a hardcoded HTTPS prefix which seems to to be configurable?

enter image description here

2
  • 3
    There are multiple open bugs for multisite plus SSL. Either use SSL for all sites … or forget it.
    – fuxia
    Commented Aug 3, 2014 at 11:27
  • 4
    thanks @toscho - it would be wonderful if you could also put some links to these bugs, this would count as a valid answer.
    – sorin
    Commented Aug 4, 2014 at 11:20

4 Answers 4

3

Thanks to @Sorin for posting the trac. From there I found a solution using just filters in functions.php (so no editing the core)

Thanks @mensmaximus for posting there:

Link: https://core.trac.wordpress.org/ticket/33887#comment:3

<?php
add_filter( 'network_admin_url', 'mmx_network_admin_url', 1, 2 );
function mmx_network_admin_url( $url, $path ){
    $url = "https://my_master_domain/wp-admin/network/" . $path;
    return $url;
}

add_filter( 'admin_url', 'mmx_admin_url', 1, 3 );
function mmx_admin_url( $url, $path, $blog_id ) {
    $blog_id = ( $blog_id ) ? $blog_id : get_current_blog_id();
    if ( preg_match( '|^http(s)?://|', $url) ) {
        $blog_details = get_blog_details( $blog_id );
        $url = $blog_details->siteurl . '/wp-admin/' . $path;
    }
    return $url;
}
1
  • 1
    Great work, thanks for sharing. I can confirm that this still works for upgrading DB from WP 5.03. to 5.1
    – rob_st
    Commented Feb 22, 2019 at 9:55
2

This is an old question, but I figured I'd post my answer as I just had to deal with this problem and figured out a temporary workaround that got it to work for me.

WARNING: This requires modifying core which is NOT recommended. If you use this workaround, you should probably remove the workaround when you've finished updating.

As of WP 4.1, the problem exists in /wp-admin/network/upgrade.php line 67. Here, $upgrade_url is being passed to wp_remote_get(). But $upgrade_url is getting its SSL cues from your current page. So if your current page is HTTPS, then it will adopt HTTPS for all of the sites that are being upgraded, even if those sites aren't supposed to be HTTPS.

Now, from the code, it seems like you should be able to filter admin_url() in order to change $upgrade_url from HTTPS to HTTP. However, when I tried this filter, it didn't work. So what I ended up having to do was insert the following code right before wp_remote_get() on line 67:

if( strpos( $url, $your_ssl_domain ) === false )
    $upgrade_url = str_replace( 'https', 'http', $upgrade_url );

Hope that helps someone.

4
  • Can you please provide a link to a bug or change request, as this seems to be a fix to a known bug and making a local fix does not make sense, we need to fix the core.
    – sorin
    Commented Feb 21, 2015 at 19:03
  • I doubt this is the best way to fix it. It just worked in my particular case and I figured I'd share what I did.
    – Sam
    Commented Feb 23, 2015 at 16:21
  • see wordpress.stackexchange.com/a/179916/944 -- almost fixed.
    – sorin
    Commented Mar 2, 2015 at 11:59
  • Thanks for this. Definitely saved my skin on our ~10k multisite install! Unfortunately, waiting months and months for a patch to be approved isn't really an option when you've got a halfway-upgraded multisite network. While not pretty, I don't see any negative consequences to this. Heck, I was considering just writing a one-off script to cURL the upgrade script for every site in our network... Thanks again.
    – rinogo
    Commented Apr 12, 2016 at 23:35
1

This is currently a known bug and already has a patch submitted for review. Feel free to add your feedback directly to the raised bug:

https://core.trac.wordpress.org/ticket/31405

1
-5

We can add https in very simple way.... No need to had code all these in any hook....

  1. Log in to wordpress admin
  2. Go to Settings > General
  3. Find WordPress Address (URL) and Replace HTTP with HTTPS
  4. Find Site Address (URL) and Replace HTTP with HTTPS
  5. Click Save Changes

Edit .htaccess file and add bellow code

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^huepixel\.com$ [NC]
RewriteRule ^ https://www.your domain.com%{REQUEST_URI} [L,R=301]

Install wordpress-https Plugin and configure it....

That's All

For multisite you can configure accordingly.

3
  • 2
    Please don't post links as answers. Links die, which in turn kills an answer. Dead answers is useless and are buried. So please file an edit and add all relevant info from the link inside your answer through an edit Commented Dec 19, 2014 at 16:24
  • 1
    Please address the issues mentioned in the question. Be specific.
    – fuxia
    Commented Dec 19, 2014 at 16:34
  • This answers seems to have nothing to do with multisite wordpress and secured and unsecured domains. Seems to be only related to securing wordpress single site.
    – sorin
    Commented Dec 31, 2014 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.