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

HTTPS server feature #183

Closed
wants to merge 2 commits into from
Closed

HTTPS server feature #183

wants to merge 2 commits into from

Conversation

mrpinkcat
Copy link

@mrpinkcat mrpinkcat commented Sep 12, 2019

HTTPS server feature

The pull request from the issue #182

You can now start a HTTPS server with credentials

const port = 3000;

const privateKey = fs.readFileSync(env_1.config.tls.key, 'utf8');
const certificate = fs.readFileSync(env_1.config.tls.cert, 'utf8');
const credentials = { key: privateKey, cert: certificate };

new BootBot(...).start(port, credentials);

@mrpinkcat
Copy link
Author

@Charca What do you think about that ?

Copy link
Owner

@Charca Charca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @mrpinkcat, thanks for adding the docs. I just left a question for ya.

});
if (credentials) {
// Start the HTTPS server
this.httpsServer = https.createServer(credentials, this.app);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are the benefits of using a separate variable here (httpsServer) instead of assigning it to this.server? That way you wouldn't need the if statement in the close() method.

@Alfirian
Copy link

Alfirian commented Dec 4, 2020

If you have different certificates files, you cans use the next:


const https_option = {
  key: fs.readFileSync('path_key_file.key', 'utf8'),
  cert: fs.readFileSync('path_cert_file.crt', 'utf8'),
  ca: [
    fs.readFileSync('path_DomainValidationSecureServerCA_cert_file.crt'),
    fs.readFileSync('USERTrustpath_cert_file.crt')
  ]
}

bot.start(process.env.PORT, https_option)

That works for me 👍

@mrpinkcat mrpinkcat closed this Jun 1, 2023
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

Successfully merging this pull request may close these issues.

3 participants