1

When I run this command

command: daphne -e ssl:443:privateKey=key.pem:certKey=crt.pem server.asgi:application --port 8000 --bind 0.0.0.0

The error I get is as follows

Starting server at ssl:443:privateKey=key.pem:certKey=crt.pem, tcp:port=8000:interface=0.0.0.0 HTTP/2 support enabled Configuring endpoint ssl:443:privateKey=key.pem:certKey=crt.pem Traceback (most recent call last): ...

FileNotFoundError: [Errno 2] No such file or directory: '/usr/src/app/crt.pem'

Can someone tell how to fix this error?

Joseph Adam
  • 1,341
  • 3
  • 21
  • 47

1 Answers1

2

Install tls and http2. I see that you have everything installed. This is for clarification.

pip install -U 'Twisted[tls,http2]'

You can use your own privateKey and certKey for testing.

I will run commands in the /home/user/Documents/ssl/

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout selfsigned.key -out selfsigned.crt

Run the application

daphne -e ssl:8000:privateKey=/home/user/Documents/ssl/selfsigned.key:certKey=/home/user/Documents/ssl/selfsigned.crt myapp.asgi:application

Output

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

If you have ".pem" files from Let's Encrypt, paste them in place of the self-signed ones.

Rony Macfly
  • 210
  • 2
  • 4
  • 10