Skip to content

How to configure webhook with self-signed certificate? #778

Answered by evilsprut
mixalezhnev asked this question in Q&A
Discussion options

You must be logged in to vote

First, a self-signed certificate cannot be set for a route or for a telegraph (specially). Self-signed certificate can be set for web server. So you have two options, install a certificate for your NestJs server or create a separate server for the Telegraf webhook.

Example 1:

const app = await NestFactory.createApplicationContext(AppModule);
const bot = app.get(getBotToken());

const tlsOptions = {
  key: fs.readFileSync('server-key.pem'),
  cert: fs.readFileSync('server-cert.pem'),
  ca: [
    fs.readFileSync('client-cert.pem')
  ]
}

bot.telegram.setWebhook('https://server.tld:8443/secret-path', {
  certificate: { source: fs.readFileSync('server-cert.pem') }
})

bot.startWebhook('/secre…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@mixalezhnev
Comment options

@evilsprut
Comment options

@mixalezhnev
Comment options

@evilsprut
Comment options

Answer selected by mixalezhnev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants