I have a subdomain wildcard SSL certificate, to cover all sites at *.mydomain.com. This is working great in Aegir 7.x-3.x - I can spin up lots of *.mydomain.com, and they can all share the same SSL cert.

I just noticed a bug though: if I delete one of the sites, it removes the certificate record from the {hosting_ssl_cert} table, so all sites in Aegir report "(certificate deleted)".

I was able to fix it by manually restoring the record in the {hosting_ssl_cert} table.

There needs to be a check to see if any other sites are using a cert before it is deleted from {hosting_ssl_cert}.

Comments

m.stenta created an issue. See original summary.

m.stenta’s picture

Project: Provision » Hosting

I think this is actually an issue in the Hosting SSL module.

m.stenta’s picture

Seems to be something wrong with this query in hosting_ssl_clean_keys($node) of hosting_ssl.nodeapi.inc:

  // Check if there are still sites using this site's certificate.
  if (!db_query("SELECT * FROM {hosting_ssl_site} siteA
                   INNER JOIN {hosting_ssl_site} siteB ON siteA.ssl_key = siteB.ssl_key
                   INNER JOIN {hosting_site} s ON s.nid = siteA.nid
                     WHERE siteA.nid <> siteB.nid
                       AND siteA.ssl_enabled = :siteA_ssl_enabled
                       AND s.status <> :s_status
                       AND siteB.nid = :siteB_nid;",
                 array(
                   ':siteA_ssl_enabled' => 1,
                   ':s_status' => HOSTING_SITE_DELETED,
                   ':siteB_nid' => $node->nid,
                 ))->fetchField()) {
m.stenta’s picture

OK - here's the issue in my case:

In {hosting_ssl_site}, all of the SSL-enabled sites that I'm running have a "2" in their "ssl_enabled" column. That's because my SSL certificate has an ID of "2" in the {hosting_ssl_cert} table.

But in the query, it's filtering out any rows that don't have "ssl_enabled = 1" - which is all my sites.

So it seems that the issue is on line 427:

                   ':siteA_ssl_enabled' => 1,

That should be using the certificate ID of the site being deleted... not a hard-coded "1". Right?

m.stenta’s picture

Hmm... oh wait... I'm also seeing now that there is an "ssl_key" column in the {hosting_ssl_site} table - which is also set to "2" in all my SSL sites.

So why would all my sites have "ssl_enabled" set to 2, instead of 1? I guess that's the real question...

m.stenta’s picture

Ah ha! Of course...

It's because all my sites have SSL set to "Required" - which corresponds to an "ssl_enabled" status of "2"!

So we just need to fix that query so that it includes sites with EITHER an "ssl_enabled" of "1" OR "2"...

m.stenta’s picture

Status: Active » Needs review
StatusFileSize
new1.03 KB

Patch attached!

gboudrias’s picture

Thanks for the patch, I figured we were missing something here. This is pretty important and I'll test and commit it as soon as possible.

gboudrias’s picture

Priority: Normal » Major
gboudrias’s picture

Status: Needs review » Reviewed & tested by the community

Works great! Drupal.org's Git system is being wonky right now, I'll commit it as soon as someone fixes it.

ergonlogic’s picture

We should really get rid of the magic numbers here and replace them with constants like HOSTING_SSL_ENABLED and HOSTING_SSL_REQUIRED.

ergonlogic’s picture

Status: Reviewed & tested by the community » Needs work
tvl’s picture

StatusFileSize
new1 KB

Until we find a proper solution here is a fix for the patch that applies on the 3.4

tvl’s picture

tvl’s picture

The patch works on 3.5

ergonlogic’s picture

Status: Needs work » Needs review
StatusFileSize
new1023 bytes

Previous patch doesn't apply for me...

Anyway, I meant something along these lines. Can anyone review/test?

ergonlogic’s picture

StatusFileSize
new1.14 KB

Oops weird whitespace on that... take 2.

tvl’s picture

Apply manually and delete & recreate a site. Everything seems good.

ergonlogic’s picture

@tvl: so you've tested this? Can you update the status to RTBC?

tvl’s picture

I applied it manually over the last fix and it works.
If you want I can test it over a clean install tomorrow.

tvl’s picture

Status: Needs review » Reviewed & tested by the community

  • helmo committed 5a54fcb on 7.x-3.x authored by m.stenta
    Issue #2606700 by ergonlogic, m.stenta, tvl: Shared SSL cert deleted...
helmo’s picture

Status: Reviewed & tested by the community » Fixed

Thanks all, looks good.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.