Botkit: SSL/HTTPS for Slack

Created on 19 Sep 2016  路  3Comments  路  Source: howdyai/botkit

Hello!

I'm trying to enable SSL so I can package my bot and its slash commands into a Slack app.

I modified SlackBot.js this way:

    slack_botkit.webserver = express();
    slack_botkit.webserver.use(bodyParser.json());
    slack_botkit.webserver.use(bodyParser.urlencoded({ extended: true }));
    slack_botkit.webserver.use(express.static(static_dir));

    https.createServer({
      key: fs.readFileSync('/aaa/xxxx.com.key'),
      cert: fs.readFileSync('/aaa/xxxx.com.crt')
    }, slack_botkit.webserver).listen(
        slack_botkit.config.port,
        function() {
            slack_botkit.log('** Starting webserver on port ' +
                    slack_botkit.config.port);
            if (cb) { cb(null, slack_botkit.webserver); }
        });

When I try to import the command into slack, it says "Yikes! It looks like your TLS certificate isn't trusted." I tried changing to another CA, and still got the same error message. Any help would be more than welcome.

Most helpful comment

Wanted to comment and let you know that you just saved me a whole lot of time and I appreciate your documentation of this issue!

All 3 comments

Update: Just FYI the bot is running properly and all otherwise

Fixed! Got in touch with Slack and they said "Slack requires the entire certificate chain is sent by the server." I saw this entry on stackoverflow: http://stackoverflow.com/questions/32777760/how-to-fix-missing-an-intermediate-chain-certificate-in-nodejs and fixed my code accordingly (in addition to adding my code from intermediate.crt to the text of my certificate), which worked:

    https.createServer({
      key: fs.readFileSync('xx'),
      cert: fs.readFileSync('xx'),
      requestCert: true,
        rejectUnauthorized: false 
    }, slack_botkit.webserver).listen(
        slack_botkit.config.port,
        function() {
            slack_botkit.log('** Starting webserver on port ' +
                    slack_botkit.config.port);
            if (cb) { cb(null, slack_botkit.webserver); }
    });

Wanted to comment and let you know that you just saved me a whole lot of time and I appreciate your documentation of this issue!

Was this page helpful?
0 / 5 - 0 ratings