telegram-bot-api: Document Requirements for Self Signed Certs without DNS and error on SetWebhook

I recently had a bot using a self signed cert. Once the cert expired, no self signed cert I could generate would permit telegram to communicate with my server. I tried putting the IP in the CN, and in Subject alternative names.

There was some unexpected behavior. The setWebhook endpoint gave a 200 response with the {"Ok": true} success indicator in the body. However, according to my nginx log, telegram did not attempt to call my bot server. I confirmed and reconfirmed that the server URL was available and correct in the API call, and verified the certificate reflected what I installed in my browser.

When calling getWebhookInfo, the last error read https://core.telegram.org/bots/self-signed{error:0A000086:SSL routines::certificate verify failed} I even tried using the exact method on the self signed guide..

Having this error without web traffic implies that telegram found an issue with the cert without calling my server, which means for a better dev experience, it could have given a 400 bad request status when the webhook was set.

Asks:

  • Document the requirements for self signed certs for IP servers. There was clearly some change since last year when a self signed worked. Explicitly state required cert fields and what telegram’s server looks for.
  • If a certificate’s invalidity can be established without calling the webhook, add this check to the setWebhook.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

This is also incorrect. The HTTPS request can be sent to any IP address. The web server serving requests on the address will provide a certificate, which will be checked using the provided root certificate and the check can succeed. In this procedure nothing depends on the actual target of the request.

You’re right, I forgot about the use case of self signed 😃 Forget the point about checking the cert for DNS/IP.

There are no certificate “comparison” in TLS. This would provide no security guarantees. The validity is derived in exactly the same way by verifying chain of certificate signatures from the root certificate to the certificate provided by the web server. This is more the meat of the issue. I suspect this ties into what I asked earlier - is this type of functionality provided by library and thus inaccessible.

I realize it’s unconventional to do a “comparison”, but this is born of the idea that I’m providing a self signed cert to begin with.

I’m realizing now that when you account for unpredictably long chains, my ask is probably too much overhead to be worth what I was hoping for, because you’d have to tell TLS to verify the server cert against the root but simultaneously ignore the fields in the server cert… definitely out of scope.

Thanks for your time