php – certificate verify failed Telegram

Question:

Good day. There was a need to write a telegram bot using WebHook. There is a self-signed certificate from Let's Encrypt. I am sending a certificate of the * .pem format via CURL, when I request "getWebhookInfo" again, I get the following error:


    SSL error {337047686, error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed}

The certificate has been verified as "SSL Server Certificate".

The array with the certificate is sent – 100%. I tried to install the generated certificate – it also returns an error. Maybe you need to send a different "SSL Server Certificate"?

Answer:

A very common mistake, in this case, you throw a certificate to the telegram, but he thinks that this certificate has been verified and expects a full check. The solution is very simple in the curl request, put the @ sign in front of the certificate This will mean that the certificate is self-signed (I understand that let's encrypt is not self-signed, but in this case it seems to me that the certificate is completely verified and is not needed, the telegram is encrypted – you will decrypt it, everything is simple) It should work out So:

curl -F "url=https://ваш айпи или доменное имя:порт/" -F "certificate=@путь к сертификату(ну или перейдите в папку где он лежит и можно просто указать имя)" "https://api.telegram.org/botТОКЕНБОТА/setwebhook"

If you want a "live example))":

curl -F "url=https://177.177.177.77:443/" -F "certificate=@tele.pem" "https://api.telegram.org/bot321321321:dsad1k3j2b3jj321h/setwebhook"
Scroll to Top