I create simple tornado http server with ssl_options and set web hook for Telegram bot, but server didn't get "post" request. What problem can be?
import tornado.httpserver
import tornado.ioloop
import tornado.web
class MainHandler(tornado.web.RequestHandler):
def post(self):
print('Post request')
def get(self):
print('Get request')
self.write('<h1>Hello, World</h1>')
application = tornado.web.Application([
(r'/', MainHandler)
])
if __name__ == '__main__':
http_server = tornado.httpserver.HTTPServer(application, ssl_options={
'certfile': 'server.crt',
'keyfile': 'server.key'
})
http_server.listen(443)
tornado.ioloop.IOLoop.current().start()
When issuing a self-signed SSL certificate, make sure 'Common Name' matches your FQDN ( hostname -f
).
Example:
$ openssl req -new -x509 -nodes -newkey rsa:1024 -keyout server.key -out server.crt -days 3650
If you are using python-telegram-bt
you can test SSL handshake running this script and trying to connect using wget:
$ wget -O /dev/null https://$HOST:$PORT/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.