Skip to content

API to use the generated certificates  #20

Description

@onerinas

How would you like to expand the functionalities?
Ability to generate and use certs directly for the existing server

Are there alternatives?

  • Alternative is to use express app included in htttps-localhost but it cannot be used in cases like socket since app.listen won't work.
    https://socket.io/docs/#Using-with-Express
  • Another alternative is to use mkcert directly to generate the cert. This is an extra step to download the certs whereas https-localhost does that automatically and developer doesn't have to run commands for that

Is it a breaking change?
Probably yes, depending upon what would be resulting API when this feature is implemented

Activity

  1. daquinoaldo commented on Aug 22, 2019

    @daquinoaldo
    Owner

    Hi @onerinas!

    Take a look to the getCerts() functions. I could try to make it available programmatically.
    Then you can start the server with https.createServer(await getCerts(), app).listen(port)

    Otherwise, we can add a parameter to the createServer() or the listen() functions to pas the app, but I'm not sure that cover all the possibilities. Probably a lambda would be better but at this point providing getCerts() would be more or less the same.

    PS: I will be on a trip next week, don't throw in the towel if you don't hear me, I'll be back next weekend and I'll read all the messages ;)

  2. onerinas commented on Aug 22, 2019

    @onerinas
    Author

    No problem at all, enjoy your trip and thank you for the quick response!

    Then you can start the server with https.createServer(await getCerts(), app).listen(port)

    Yes, I was hoping for something like that.

  3. daquinoaldo commented on Aug 22, 2019

    @daquinoaldo
    Owner

    Fine, next weekend I'll try to rearrange the structure to expose getCerts() 👌

  4. onerinas commented on Aug 22, 2019

    @onerinas
    Author

    I've forked the repo to use in our project. Here is the commit: onerinas@ae6386e

    usage:
    https.createServer(await httpsLocalhost.getCerts(), app)

    I don't have any tests to create a PR here.

  5. daquinoaldo commented on Aug 30, 2019

    @daquinoaldo
    Owner

    Hi @onerinas,
    I checked your PR #22 but contains breaking changes.

    In particular, it changes the current use from

    const httpsLocalhost = require("https-localhost")
    const app = httpsLocalhost()

    to

    const httpsLocalhost = require("https-localhost").app
    const app = httpsLocalhost()

    Actually, I won't push a breaking change now. Maybe in the future, but I will totally remove express in that case.

    I've created a branch that should solve your problem.

    I paste an example for clarity:

    const httpsLocalhost = require("https-localhost")()
    // const app = ...
    // const port = 443
    const certs = await httpsLocalhost.getCerts()
    const server = https.createServer(certs, app).listen(port)

    Let me know if this solution can work for you.

  6. onerinas commented on Aug 30, 2019

    @onerinas
    Author

    Yes, this would work!

  7. daquinoaldo commented on Aug 30, 2019

    @daquinoaldo
    Owner

    Fine!

    I'll publish it in the next few days together with other changes.

  8. added a commit that references this issue on Sep 2, 2019
    0524415
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions