Telegram Bot + SSL woes

So I decided to make a telegram bot. I started off having some idea of how to go about doing this, but ended up realising I knew nothing about this, as with everything in my life. I did however, learned a lot about the workings of the telegram API and how webhooks work. This should be simple enough in theory but I soon found out it isn’t.

Although the title of this post is about a telegram bot, my troubles came about trying to set up a webhook with telegram to my own server.

Alert: Rookie mistakes ahead!

I already ensured that I had a valid SSL cert and the webhook was set. Somehow telegram’s getWebhookInfo returned this:

{
    "ok":true,
    "result":{
        "url":"YOUR WEBHOOK CALLBACK URL",
        "has_custom_certificate":false,
        "pending_update_count":32,
        "last_error_date":1486903822,
        "last_error_message":"SSL error {336134278, error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed}",
        "max_connections":40
    }
}

May I direct your attention here: ssl3_get_server_certificate:certificate verify failed Apparently, my certificate was not found or something.

Further digging revealed that my SSL was never properly installed. Apparently a “chained certificate” was needed instead of just a single domain certificate. Looking around online I found that I needed an intermediate certificate given by my SSL provider. More head bashing and eye-gouging later, I realised that my provider gave an .ca-bundle instead.

I just ran the concatenate command cat domain_com.crt domain_com.ca-bundle > ssl-bundle.crt to combine everything into a single ssl-bundle.crt. Very frustrating at the time, but glad everything turns out alright.