Search code examples
curlssl-certificatetelegramtelegram-bottelegram-webhook

Telegram Bot Webhook Not Verifying My SSL Certificate


I've got a website with trusted SSL certificate Version 3. There are 4 files I got from the SSL issuer that one of them is the Domain Certificate put on the server.

To set webhook for my bot I've tried:

  1. The simple setWebhook method in URL mode:

    https://api.telegram.org/bot447278997:*******************************nZW0/setWebhook?url=https://example.com/webhookMethod
    
  2. setWebhook using Curl. I've uploaded each and every one of the 4 files from certificate issuer, and also a file containing all 4 files in random order. (the curl command recognized my certificate as self-signed and returned a SSL(60) error, so I had to add a --insecure word to the command in order to ignore the validation of the certificate and just send it). here's the command:

    curl --insecure -F "url=https://example.com/webhookMethod" -F "[email protected]" https://api.telegram.org/bot447278997:****************************nZW0/setWebhook
    

None of the methodes above made my webhook work. calling getWebhookInfo method, I got an error every time like:

{
  "ok":true,
  "result":{
    "url":"https://example.com/webhookMethod",
    "has_custom_certificate":true,
    "pending_update_count":7,
    "last_error_date":1518169667,
    "last_error_message":"Wrong response from the webhook: 302 Found",
    "max_connections":40
  }
}

In some tries has_custom_certificate turned into False or the last_error_message changed to something like not verified certificate or SSL error , etc.

In addition, I've tested my web service with Postman having SSL verification and it's all set up and working. I also know that Telegram does not support SSL Version 2 and 3 but supports self-signed certificates. Now that I'm sending them a verified version 3 certificate it should work, right?

Any help is appreciated in advance.


Solution

  • its not ssl problem. you should return 200 at the response not 302. as far as i know 302 means redirect. do not redirect the in the response message.