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

后端 未结 9 940
生来不讨喜
生来不讨喜 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 18:02

    Similar to django-sslserver you could use RunServerPlus from django-extensions

    It has dependencies on Werkzeug (so you get access to the excellent Werkzeug debugger) and pyOpenSSL (only required for ssl mode) so to install run:

    pip install django-extensions Werkzeug pyOpenSSL
    

    Add it to INSTALLED_APPS in your projects settings.py file:

    INSTALLED_APPS = (
        ...
        'django_extensions',
        ...
    )
    

    Then you can run the server in ssl mode with:

    ./manage.py runserver_plus --cert /tmp/cert
    

    This will create a cert file at /tmp/cert.crt and a key file at /tmp/cert.key which can then be reused for future sessions.

    There is a bunch of extra stuff included in django-extensions that you may find of use so it is worth having a quick flick through the docs.

提交回复
热议问题