How can I test https connections with Django as easily as I can non-https connections using 'runserver'?

后端 未结 9 922
生来不讨喜
生来不讨喜 2020-11-28 17:55

I have an application that uses \"secure\" cookies and want to test it\'s functionality without needing to set up a complicated SSL enabled development server. Is there any

相关标签:
9条回答
  • 2020-11-28 18:19

    Signup to https://ngrok.com/. You can use https to test. This might help people who just want to quickly test https.

    0 讨论(0)
  • 2020-11-28 18:22

    I would recommend using the django-sslserver package.

    The current package on PyPI only supports up to Django version 1.5.5 but a patch has been committed via 5d4664c. With this fix the system runs well and is a pretty simple and straightforward solution for testing https connections.

    UPDATE: Since I posted my answer the commit above has been merged into the master branch and a new release has been pushed to PyPI. So there shouldn't be any need to specify the 5d4664c commit for that specific fix.

    0 讨论(0)
  • 2020-11-28 18:25

    It can be done in one line with socat:

    socat openssl-listen:8443,fork,reuseaddr,cert=server.pem,verify=0 tcp:localhost:8000
    

    , where 8443 is a port to listen for incoming HTTPS connections, server.pem is a self-signed server certificate and localhost:8000 is a debug HTTP server launched as usual.

    More details: http://www.dest-unreach.org/socat/doc/socat-openssltunnel.html

    0 讨论(0)
提交回复
热议问题