I’m having trouble setting up a Telegram bot with SSL certificates. I followed these steps but I’m getting SSL errors.
First, I obtained my bot token from BotFather. Then I created a self-signed certificate using this command:
openssl req -newkey rsa:2048 -sha256 -nodes -keyout private.key -x509 -days 365 -out public.pem -subj "/C=US/ST=California/L=San Francisco/O=MyCompany/CN=mydomain.example"
After that, I started the SSL server:
openssl s_server -accept 443 -key private.key -cert public.pem
Next, I set up the webhook:
curl -F "url=https://myserver:443/webhook" -F "[email protected]" https://api.telegram.org/botMYTOKEN/setWebhook
The response was successful: {"ok":true,"result":true,"description":"Webhook was set"}.
However, when Telegram tries to connect to my server, I receive this SSL error:
140234567890123:error:14094416:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate unknown:s3_pkt.c:1257:SSL alert number 46
When I test with openssl s_client -connect myserver:443, it works fine.
How can I simulate the Telegram client connection to debug this? Using -cert public.pem with s_client doesn’t help. What is the correct way to resolve this SSL issue and receive webhook data?