Bolt-js: Possible to run bolt app via HTTPS?

Created on 9 Aug 2019  路  8Comments  路  Source: slackapi/bolt-js

Description

Is it possible to run bolt using https instead of http? wondering if this request will require me having to fork.

What type of issue is this? (place an x in one of the [ ])

  • [ ] bug
  • [ ] enhancement (feature request)
  • [X ] question
  • [ ] documentation related
  • [ ] testing related
  • [ ] discussion

Requirements (place an x in each of the [ ])

  • [ x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x ] I've read and agree to the Code of Conduct.
  • [x ] I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Reproducible in:

package version:

node version:

OS version(s):

Steps to reproduce:

1.
2.
3.

Expected result:

What you expected to happen

Actual result:

What actually happened

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

enhancement

Most helpful comment

Hey folks, I'd like to start working on this soon. While evaluating some ideas, I think we would instead like to add HTTPS related options as the second argument to .start() (where the first argument is already port).

This approach helps us avoid adding more options to ExpressReceiverOptions, which in turn need to be added to AppOptions. It's a small benefit, but there doesn't seem to be any significant downside to grouping the HTTPS related options into the same place you specify your port.

Open to any thoughts here, but we're looking to make this happen pretty quickly (like in the next 1-2 days) so the earlier the better.

All 8 comments

Right now the server only uses HTTPS unfortunately. We're definitely open to extending the constructor to make this possible (it's even a comment in the code https://github.com/slackapi/bolt/blob/master/src/ExpressReceiver.ts#L42) but we haven't had the opportunity to get around to it yet.

No problem sounds good if I have some time I'll check it out

Temporary solution while ExpressReceiver isn't upgraded to be able to run https:

const { App, ExpressReceiver } = require('@slack/bolt');
const https = require('https');
const clientTls = {
    key: fs.readFileSync('path/to/key.pem'),
    cert: fs.readFileSync('path/to/cert.pem')
};
const expressReceiver = new ExpressReceiver({
    signingSecret: signingSecret,
    clientTls: clientTls
});
// Initialize the app
const app = new App({
    ...   
    receiver: expressReceiver
});
...

https.createServer(clientTls, expressReceiver.app).listen(port);

You can also create a custom receiver and then override the self.server variable, which is very similar to @gvashchenkolineate's answer.

const { ExpressReceiver } = require("@slack/bolt");
const { createServer } = require("https");

class CustomReceiver extends ExpressReceiver {
    constructor (kwargs) {
        super(kwargs);
        this.server = createServer({
            key: kwargs.clientTls.key,
            cert: kwargs.clientTls.cert
        }, this.app);
    }
};

module.exports = { CustomReceiver };

@zachsirotto Yours is way better solution. Should use it. Thanks!

_any progress here?
if not, i would make my app using @zachsirotto solution.
thanks @zachsirotto_

new.
i found clientTls param in app constructor. i will use it

Hey folks, I'd like to start working on this soon. While evaluating some ideas, I think we would instead like to add HTTPS related options as the second argument to .start() (where the first argument is already port).

This approach helps us avoid adding more options to ExpressReceiverOptions, which in turn need to be added to AppOptions. It's a small benefit, but there doesn't seem to be any significant downside to grouping the HTTPS related options into the same place you specify your port.

Open to any thoughts here, but we're looking to make this happen pretty quickly (like in the next 1-2 days) so the earlier the better.

I believe this is already resolved by the pull request https://github.com/slackapi/bolt-js/pull/658

Feel free to reopen if you see issues with the latest version.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

johnsonyick picture johnsonyick  路  4Comments

dschinkel picture dschinkel  路  4Comments

kmartin-215 picture kmartin-215  路  5Comments

st3fan picture st3fan  路  3Comments

jamesfmac picture jamesfmac  路  5Comments