This is an webserver to be used as a webhook for a Telegram Bot. It means it uses tlsv1.2 from openssl libraries. Since this is a self-signed HTTP webserver, the certificate has to be uploaded manually. You will find furthere information below. Take into account, in order to reply messages, you need a tsl/ssl client, and it cannot be done through WebHook, it only can be done using the URL API.
After running make, you are ready to go.
- Go to sslkeys folder
$ cd telegramBot-WebHook/server/sslkeys
- Open the generator bash to edit
$ nano genkeys.sh
- Edit the generator bash with your information. In the openssl line, set your public IP as CN
openssl req -newkey rsa:2048 -sha256 -nodes -keyout my-ssl-private.key\
-x509 -days 365 -out my-ssl-public.pem\
-subj "/C=US/ST=New York/L=Brooklyn/O=bot company/CN=<Public IP>"
- On the same file. In the line curl, your public IP and your telegram Bot TOKEN are needed. This is used to upload your public key to the telegram api server:
curl -F "url=https://<Public IP>/" -F "certificate=@sslkeys/my-ssl-public.pem"\
https://api.telegram.org/bot<TELEGRAM BOT API TOKEN>/setWebhook
- Add execution feature to the file
$ chmod +x genkeys.sh
- Generate the private and public keys and upload your public to the telegram server
$ ./genkeys.sh
- Go back to the server folder
$ cd ../
- (Optional) start a screen
$ screen
- On the new screen created, run the server
$ sudo ./main
- openssl (libssl-dev)
- (optional) screen