Answer the question
In order to leave comments, you need to log in
How to correctly specify the certificate for the Telegram api?
Installing webhook for Telegram bot.
I use irazasyed/telegram-bot-sdk
I connected certificates from Let's encrypt to the domain. It created 4 files:
cert.pem
chain.pem
fullchain.pem
privkey.pem
nginx host settings set fullchain.pem and private.pem as private
listen 123.456.789:443 ssl;
ssl on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_certificate /etc/letsencrypt/live/example.ru/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.ru/privkey.pem;
use Telegram\Bot\Api;
$telegram = new Api('мой_токен_бота');
$telegram->setWebhook([
'url' => 'https://example.ru/tgbot',
'certificate' => __DIR__ . '/cert/fullchain.pub'
]);
$tg = new Telegram($token);
print_r($tg->getWebhookInfo());
SSL error {336134278, error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed}
Answer the question
In order to leave comments, you need to log in
I'll add info for those who don't know.
Now Telegram already accepts self-signed certificates from Let's encrypt, it is enough to install the certificate on the server, in the case of nginx:
listen 443 ssl;
ssl on;
ssl_certificate /etc/letsencrypt/live/domain/cert.pem;
ssl_certificate_key /etc/letsencrypt/live/domain/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/domain/fullchain.pem;
and send fullchain.pem to telegram with the command:
curl -F "url= https://domains/ webhook address" -F "certificate=fullchain.pem" " https://api.telegram.org/botTOKEN/setwebhook "
I'll answer myself)
For some reason, Telegram did not want to accept a certificate from Let's encrypt.
I ordered a certificate in the register - I accepted it without problems.
Same self-signed accepted
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question