While the bot wrote I used the ngrok service, everything worked, now I decided to publish on our server (web server on IIS), set up IIS as a proxy so that I would redirect requests to localhost (set up by rewriting URL addresses), send requests via browser get (for checking ) everything works, i.e. I cause the external URL goes redirecting to my local. However, the bot did not work, I began to google I realized that I needed to use the NewWebhookWithCert () method, I generated a certificate and a private key using the command

openssl.exe req -new -x509 -nodes -newkey rsa: 1024 -keyout webhook_pkey.key -out webhook_cert.pem -days 3650

in code

bot.SetWebhook(tgbotapi.NewWebhookWithCert(net.WebhookURL, "webhook_cert.pem")) 

still

 http.ListenAndServeTLS(":"+net.ListenPort, "webhook_cert.pem", "webhook_pkey.key", nil) 

and nothing, FIG know what else to do, please tell me

    1 answer 1

    Perhaps you have an incorrect certificate.

    This example states that you need to generate a certificate by specifying subject .

     openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 3560 -subj "//O=Org\CN=Test" -nodes 

     bot.SetWebhook(tgbotapi.NewWebhookWithCert(net.WebhookURL, "cert.pem")) 

    Or you can try to get a certificate using Let's Encrypt