Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNI Callback #11

Open
suhz opened this issue Sep 7, 2022 · 1 comment
Open

SNI Callback #11

suhz opened this issue Sep 7, 2022 · 1 comment

Comments

@suhz
Copy link

suhz commented Sep 7, 2022

I need a way to serve non-Letsencrypt certs together with the one managed by Greenlock. I can't find any suitable way, so I propose these little changes here: e63cdf2

with this changes, I will "ready" this HTTP(s) worker to greenlock-express

const greenlock = Greenlock
  .init({ ... })
  .ready(httpsWorker);

function httpsWorker(glx) {
  const plainServer = glx.httpServer();
  plainServer.listen(plainPort, plainAddr, () => {
    logger.info(`Greenlock listening on ${plainAddr}:${plainPort} for ACME challenges, and redirecting to HTTPS`);

    const secureServer = glx.httpsServer({ SNICallback }, app);
    secureServer.listen(securePort, secureAddr, () => {
      logger.info(`Greenlock listening on ${secureAddr}:${securePort} for secure traffic`);
    });
  });
}

And then provided my own SNICallback() like so

function SNICallback(greenlock, secureOpts, sni) {
  function SNIFallback(servername, cb) {
    return sni.create(greenlock, secureOpts)(servername, cb);
  }

  return (servername, cb) => {
    // Do something or return SNIFallback(servername, cb)
  }
}

Each time someone visits the secure port, it'll run my callback first and return it's secureContext if available, or continue to Greenlock SNI Callback as usual.

Let me know what you think

@coolaj86
Copy link
Collaborator

The way that I expected people to go about this was to modify the certificate store - for example:

If you get a request for a domain that you know is elsewhere, just read it from that location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants