安装 tls 和 http2。我看到你已经安装了所有东西。这是为了澄清。
pip install -U 'Twisted[tls,http2]'
您可以使用自己的 privateKey 和 certKey 进行测试。
我将在 /home/user/Documents/ssl/ 中运行命令
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout selfsigned.key -out selfsigned.crt
运行应用程序
daphne -e ssl:8000:privateKey=/home/user/Documents/ssl/selfsigned.key:certKey=/home/user/Documents/ssl/selfsigned.crt myapp.asgi:application
输出
user@debian:~/Documents/pythonWeb/myapp$ daphne -e ssl:8000:privateKey=/home/user/Documents/ssl/selfsigned.key:certKey=/home/user/Documents/ssl/selfsigned.crt myapp.asgi:application
2022-02-04 18:49:12,726 INFO Starting server at ssl:8000:privateKey=/home/user/Documents/ssl/selfsigned.key:certKey=/home/user/Documents/ssl/selfsigned.crt
2022-02-04 18:49:12,726 INFO HTTP/2 support enabled
2022-02-04 18:49:12,726 INFO Configuring endpoint ssl:8000:privateKey=/home/user/Documents/ssl/selfsigned.key:certKey=/home/user/Documents/ssl/selfsigned.crt
2022-02-04 18:49:12,733 INFO Listening on TCP address 0.0.0.0:8000
2022-02-04 18:49:27,644 INFO file_cache is only supported with oauth2client<4.0.0
192.168.1.106:50128 - - [04/Feb/2022:18:49:32] "GET /stream_1/" 200 2510
192.168.1.106:58251 - - [04/Feb/2022:18:49:32] "WSCONNECTING /ws/chat/stream_1/" - -
connect
如果您有来自 Let's Encrypt 的“.pem”文件,请将它们粘贴到自签名文件的位置。