Telegram Bot API Webhooks Self-signed Certificate issue

喜你入骨 提交于 2019-11-30 15:19:12
Giorgio Robino

I answer myself, to share solution found here: https://stackoverflow.com/a/33260827/1786393

the point was not the mentioned nginx configuration, but the PEM file:

openssl req -newkey rsa:2048 -sha256 -nodes -keyout YOURPRIVATE.key -x509 -days 365 -out YOURPUBLIC.pem -subj "/C=US/ST=New York/L=Brooklyn/O=Example Brooklyn Company/CN=YOURDOMAIN.EXAMPLE"

YOURDOMAIN.EXAMPLE in the subj strig of openssl must be real hostname of your server that receive webhooks.

the solution that works for me:

I generated key pairs: openssl genrsa -out webhook_pkey.pem 2048 and openssl req -new -x509 -days 3650 -key webhook_pkey.pem -out webhook_cert.pem

don't forget to give FQDN name. give your host's ip at least

added it to nginx config

server {
    listen      8443 ssl;
    server_name MY_IP;
    charset     utf-8;
    client_max_body_size 75M;
    ssl_certificate /var/www/myproject/tg_keys/webhook_cert.pem;
    ssl_certificate_key /var/www/myproject/tg_keys/webhook_pkey.pem;

    location / { try_files $uri @yourapplication; }
    location @yourapplication {
        include uwsgi_params;
        uwsgi_pass unix:/var/www/myproject/hb.sock;
    }
}

cURL options:


    CURLOPT_SSL_VERIFYPEER = false
    CURLOPT_SSL_VERIFYHOST = false

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!