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

后端 未结 9 942
生来不讨喜
生来不讨喜 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: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

提交回复
热议问题