我正在尝试使用Let's Encrypt 证书设置我的Telegram bot webhook ,但 Telegram 一直说verify_failed。但是,浏览器完全可以使用新的 Let's Encrypt 证书。
我的自签名证书目前在带有Nginx web server的Ubuntu 17.04上的 webhooks 中运行良好。
我错过了什么?
当前的自签名证书设置(Works)
我使用以下命令生成了我的证书:
openssl req -newkey rsa:2048 -sha256 -nodes -keyout my-cert.key -x509 -days 365 -out my-cert.pem -subj "/C=CA/ST=Ontario/L=Toronto/O=My Organization/CN=example.org"
和 Nginx 配置:
server {
server_name example.org www.example.org localhost;
listen 443 ssl;
listen 8080 ssl;
listen 8443 ssl;
ssl_certificate /etc/nginx/certificates/my-cert.pem;
ssl_certificate_key /etc/nginx/certificates/my-cert.key;
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
ssl_prefer_server_ciphers on;
location ~* ^/bots/mybot/webhook/.+$ {
proxy_pass http://0.0.0.0:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
新的 Let's Encrypt 设置(在浏览器中有效,在 webhook 中失败)
使用 EFF 的出色 certbot 为我的域生成证书。
在设置 Telegram 的 webhook 时,我使用/etc/letsencrypt/live/example.org/cert1.pem
file.
这是我尝试过的 Nginx 配置:
server {
server_name example.org www.example.org localhost;
listen 80;
listen [::]:80;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
if ($scheme != "https") {
return 301 https://$host$request_uri;
}
}
server {
server_name example.org www.example.org localhost;
listen 443 ssl;
listen 8080 ssl;
listen 8443 ssl;
ssl_certificate /etc/letsencrypt/live/example.org/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem; # managed by Certbot
ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
ssl_prefer_server_ciphers on;
location ~* ^/bots/mybot/webhook/.+$ {
proxy_pass http://0.0.0.0:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}