django-sslserver-v2 1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django-sslserver-v2-1.0/AUTHORS +15 -0
- django-sslserver-v2-1.0/LICENSE +7 -0
- django-sslserver-v2-1.0/MANIFEST.in +9 -0
- django-sslserver-v2-1.0/PKG-INFO +124 -0
- django-sslserver-v2-1.0/README.rst +88 -0
- django-sslserver-v2-1.0/django_sslserver_v2.egg-info/PKG-INFO +124 -0
- django-sslserver-v2-1.0/django_sslserver_v2.egg-info/SOURCES.txt +17 -0
- django-sslserver-v2-1.0/django_sslserver_v2.egg-info/dependency_links.txt +1 -0
- django-sslserver-v2-1.0/django_sslserver_v2.egg-info/requires.txt +1 -0
- django-sslserver-v2-1.0/django_sslserver_v2.egg-info/top_level.txt +1 -0
- django-sslserver-v2-1.0/pyproject.toml +52 -0
- django-sslserver-v2-1.0/requirements.txt +1 -0
- django-sslserver-v2-1.0/setup.cfg +4 -0
- django-sslserver-v2-1.0/sslserver/__init__.py +1 -0
- django-sslserver-v2-1.0/sslserver/certs/development.crt +36 -0
- django-sslserver-v2-1.0/sslserver/certs/development.key +52 -0
- django-sslserver-v2-1.0/sslserver/management/__init__.py +0 -0
- django-sslserver-v2-1.0/sslserver/management/commands/__init__.py +0 -0
- django-sslserver-v2-1.0/sslserver/management/commands/runsslserver.py +206 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Ted Dziuba <tjdziuba@gmail.com>
|
|
2
|
+
Adam Stokes <adam.stokes@ubuntu.com>
|
|
3
|
+
titusz <tp@py7.de>
|
|
4
|
+
Allan Daemon <rea.aft@gmail.com>
|
|
5
|
+
Ben Dean-Kawamura <ben@pculture.org>
|
|
6
|
+
Collin Anderson <cmawebsite@gmail.com>
|
|
7
|
+
Joseph Schilz <Joseph@Schilz.org>
|
|
8
|
+
Kevin Turner <kturner@mobilepaks.com>
|
|
9
|
+
Nguyễn Hà Dương <cmpitg@gmail.com>
|
|
10
|
+
Rob Dennis <rdennis@gmail.com>
|
|
11
|
+
Steve Gregory <contact@steve-gregory.com>
|
|
12
|
+
Yurii Zolot'ko <yurii.zolotko@elance-odesk.com>
|
|
13
|
+
myrs <mihail.nso@gmail.com>
|
|
14
|
+
Anthony Monthe (ZuluPro) <anthony.monthe@gmail.com>
|
|
15
|
+
Shashwat <shashwat13.8@gmail.com>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright (c) 2023 Shashwat
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: django-sslserver-v2
|
|
3
|
+
Version: 1.0
|
|
4
|
+
Summary: An SSL-enabled development server for Django. Supports latest versions of Django and Python
|
|
5
|
+
Author-email: Shashwat <shashwat13.8@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: django-sslserver,sslserver
|
|
8
|
+
Classifier: Environment :: Web Environment
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python
|
|
12
|
+
Classifier: Programming Language :: Python :: 2
|
|
13
|
+
Classifier: Programming Language :: Python :: 2.7
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.4
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.5
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Framework :: Django
|
|
22
|
+
Classifier: Framework :: Django :: 1.8
|
|
23
|
+
Classifier: Framework :: Django :: 1.9
|
|
24
|
+
Classifier: Framework :: Django :: 1.10
|
|
25
|
+
Classifier: Framework :: Django :: 1.11
|
|
26
|
+
Classifier: Framework :: Django :: 2.0
|
|
27
|
+
Classifier: Framework :: Django :: 2.1
|
|
28
|
+
Classifier: Framework :: Django :: 2.2
|
|
29
|
+
Classifier: Framework :: Django :: 4.0
|
|
30
|
+
Classifier: Framework :: Django :: 4.2
|
|
31
|
+
Requires-Python: >=2
|
|
32
|
+
Description-Content-Type: text/x-rst
|
|
33
|
+
License-File: LICENSE
|
|
34
|
+
License-File: AUTHORS
|
|
35
|
+
Requires-Dist: Django>=1.8
|
|
36
|
+
|
|
37
|
+
====================
|
|
38
|
+
Django SSL Server v2
|
|
39
|
+
====================
|
|
40
|
+
|
|
41
|
+
.. image:: https://img.shields.io/pypi/v/django-sslserver-v2.svg
|
|
42
|
+
:target: https://pypi.python.org/pypi/django-sslserver-v2
|
|
43
|
+
|
|
44
|
+
.. image:: https://img.shields.io/pypi/pyversions/django-sslserver-v2.svg
|
|
45
|
+
:target: https://pypi.python.org/pypi/django-sslserver-v2/
|
|
46
|
+
|
|
47
|
+
Django SSL Server v2 is a SSL-enabled development server for the Django Framework, a clone of `django-sslserver
|
|
48
|
+
<https://github.com/teddziuba/django-sslserver>`_. This project is actively maintained and supports the latest version of Django and Python.
|
|
49
|
+
|
|
50
|
+
Please note that this `should not be used for production setups
|
|
51
|
+
<https://docs.djangoproject.com/en/4.2/ref/django-admin/#runserver>`_. This
|
|
52
|
+
app is intended for special use-cases. Most people should instead do a proper
|
|
53
|
+
`production deployment
|
|
54
|
+
<https://docs.djangoproject.com/en/4.2/howto/deployment/>`_ where a real
|
|
55
|
+
webserver such as Apache or NGINX handles SSL.
|
|
56
|
+
|
|
57
|
+
Getting Started
|
|
58
|
+
===============
|
|
59
|
+
|
|
60
|
+
Install the module in your Python distribution or virtualenv::
|
|
61
|
+
|
|
62
|
+
$ pip install django-sslserver-v2
|
|
63
|
+
|
|
64
|
+
Add the application to your `INSTALLED_APPS`::
|
|
65
|
+
|
|
66
|
+
INSTALLED_APPS = (...
|
|
67
|
+
"sslserver",
|
|
68
|
+
...
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
Start a SSL-enabled debug server::
|
|
72
|
+
|
|
73
|
+
$ python manage.py runsslserver
|
|
74
|
+
|
|
75
|
+
and access app on https://localhost:8000 or start server on specified port::
|
|
76
|
+
|
|
77
|
+
$ python manage.py runsslserver 127.0.0.1:9000
|
|
78
|
+
|
|
79
|
+
IPv6 support::
|
|
80
|
+
|
|
81
|
+
$ python manage.py runsslserver -6 [::]:7443
|
|
82
|
+
|
|
83
|
+
You'll now be able to access your Django app on https://localhost:9000/
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
Browser Certificate Errors
|
|
87
|
+
==========================
|
|
88
|
+
|
|
89
|
+
Using the default settings, your local browser will make all sorts of noise that it *doesn't trust the certificate*. **This is expected.**
|
|
90
|
+
|
|
91
|
+
Django SSL Server ships "batteries included" with a self-signed server certificate. With self-signed certificates,
|
|
92
|
+
the server is effectively telling the user, "I'm such-and-such server, because I said so". Whereas, with a commercial
|
|
93
|
+
SSL certificate, the server tells the user, "I'm Bank of America, because VeriSign said so (or any other commercial certificate authority)."
|
|
94
|
+
|
|
95
|
+
There are two options for making the certificate warning go away in development:
|
|
96
|
+
|
|
97
|
+
**Option 1**: Tell your browser to explicitly trust the certificate. You can do this in your browser's "advanced settings"
|
|
98
|
+
tab, by installing ``sslserver/certs/development.crt`` as a trusted certificate. The mechanism for this varies from browser to browser.
|
|
99
|
+
|
|
100
|
+
**Option 2**: Use a certificate from a CA that your browser trusts, for example `Letsencrypt <https://letsencrypt.org>`_.
|
|
101
|
+
If you have a certificate/key pair from a certificate authority,
|
|
102
|
+
you can tell Django SSL Server to use it with the following arguments::
|
|
103
|
+
|
|
104
|
+
$ python manage.py runsslserver --certificate /path/to/certificate.crt --key /path/to/key.key
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
Third-Party Static File Handlers
|
|
108
|
+
================================
|
|
109
|
+
|
|
110
|
+
If you're using a wrapper around your WSGI application such as dj_static or WhiteNoise, you probably want to let it handle serving
|
|
111
|
+
static files. Otherwise, you may see 404s when requesting static files. You can disable the default behavior by using the ``--nostatic``
|
|
112
|
+
option.
|
|
113
|
+
|
|
114
|
+
Getting Involved
|
|
115
|
+
================
|
|
116
|
+
|
|
117
|
+
Feel free to open pull requests or issues. GitHub is the canonical location of this project.
|
|
118
|
+
|
|
119
|
+
Special Thanks
|
|
120
|
+
===============
|
|
121
|
+
Special thanks to `@teddziuba
|
|
122
|
+
<https://github.com/teddziuba>`_ for building `django-sslserver
|
|
123
|
+
<https://github.com/teddziuba/django-sslserver>`_ and all the `contributers
|
|
124
|
+
<https://github.com/shashwat2003/django-sslserver-v2/blob/master/AUTHORS>`_
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
====================
|
|
2
|
+
Django SSL Server v2
|
|
3
|
+
====================
|
|
4
|
+
|
|
5
|
+
.. image:: https://img.shields.io/pypi/v/django-sslserver-v2.svg
|
|
6
|
+
:target: https://pypi.python.org/pypi/django-sslserver-v2
|
|
7
|
+
|
|
8
|
+
.. image:: https://img.shields.io/pypi/pyversions/django-sslserver-v2.svg
|
|
9
|
+
:target: https://pypi.python.org/pypi/django-sslserver-v2/
|
|
10
|
+
|
|
11
|
+
Django SSL Server v2 is a SSL-enabled development server for the Django Framework, a clone of `django-sslserver
|
|
12
|
+
<https://github.com/teddziuba/django-sslserver>`_. This project is actively maintained and supports the latest version of Django and Python.
|
|
13
|
+
|
|
14
|
+
Please note that this `should not be used for production setups
|
|
15
|
+
<https://docs.djangoproject.com/en/4.2/ref/django-admin/#runserver>`_. This
|
|
16
|
+
app is intended for special use-cases. Most people should instead do a proper
|
|
17
|
+
`production deployment
|
|
18
|
+
<https://docs.djangoproject.com/en/4.2/howto/deployment/>`_ where a real
|
|
19
|
+
webserver such as Apache or NGINX handles SSL.
|
|
20
|
+
|
|
21
|
+
Getting Started
|
|
22
|
+
===============
|
|
23
|
+
|
|
24
|
+
Install the module in your Python distribution or virtualenv::
|
|
25
|
+
|
|
26
|
+
$ pip install django-sslserver-v2
|
|
27
|
+
|
|
28
|
+
Add the application to your `INSTALLED_APPS`::
|
|
29
|
+
|
|
30
|
+
INSTALLED_APPS = (...
|
|
31
|
+
"sslserver",
|
|
32
|
+
...
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
Start a SSL-enabled debug server::
|
|
36
|
+
|
|
37
|
+
$ python manage.py runsslserver
|
|
38
|
+
|
|
39
|
+
and access app on https://localhost:8000 or start server on specified port::
|
|
40
|
+
|
|
41
|
+
$ python manage.py runsslserver 127.0.0.1:9000
|
|
42
|
+
|
|
43
|
+
IPv6 support::
|
|
44
|
+
|
|
45
|
+
$ python manage.py runsslserver -6 [::]:7443
|
|
46
|
+
|
|
47
|
+
You'll now be able to access your Django app on https://localhost:9000/
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
Browser Certificate Errors
|
|
51
|
+
==========================
|
|
52
|
+
|
|
53
|
+
Using the default settings, your local browser will make all sorts of noise that it *doesn't trust the certificate*. **This is expected.**
|
|
54
|
+
|
|
55
|
+
Django SSL Server ships "batteries included" with a self-signed server certificate. With self-signed certificates,
|
|
56
|
+
the server is effectively telling the user, "I'm such-and-such server, because I said so". Whereas, with a commercial
|
|
57
|
+
SSL certificate, the server tells the user, "I'm Bank of America, because VeriSign said so (or any other commercial certificate authority)."
|
|
58
|
+
|
|
59
|
+
There are two options for making the certificate warning go away in development:
|
|
60
|
+
|
|
61
|
+
**Option 1**: Tell your browser to explicitly trust the certificate. You can do this in your browser's "advanced settings"
|
|
62
|
+
tab, by installing ``sslserver/certs/development.crt`` as a trusted certificate. The mechanism for this varies from browser to browser.
|
|
63
|
+
|
|
64
|
+
**Option 2**: Use a certificate from a CA that your browser trusts, for example `Letsencrypt <https://letsencrypt.org>`_.
|
|
65
|
+
If you have a certificate/key pair from a certificate authority,
|
|
66
|
+
you can tell Django SSL Server to use it with the following arguments::
|
|
67
|
+
|
|
68
|
+
$ python manage.py runsslserver --certificate /path/to/certificate.crt --key /path/to/key.key
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
Third-Party Static File Handlers
|
|
72
|
+
================================
|
|
73
|
+
|
|
74
|
+
If you're using a wrapper around your WSGI application such as dj_static or WhiteNoise, you probably want to let it handle serving
|
|
75
|
+
static files. Otherwise, you may see 404s when requesting static files. You can disable the default behavior by using the ``--nostatic``
|
|
76
|
+
option.
|
|
77
|
+
|
|
78
|
+
Getting Involved
|
|
79
|
+
================
|
|
80
|
+
|
|
81
|
+
Feel free to open pull requests or issues. GitHub is the canonical location of this project.
|
|
82
|
+
|
|
83
|
+
Special Thanks
|
|
84
|
+
===============
|
|
85
|
+
Special thanks to `@teddziuba
|
|
86
|
+
<https://github.com/teddziuba>`_ for building `django-sslserver
|
|
87
|
+
<https://github.com/teddziuba/django-sslserver>`_ and all the `contributers
|
|
88
|
+
<https://github.com/shashwat2003/django-sslserver-v2/blob/master/AUTHORS>`_
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: django-sslserver-v2
|
|
3
|
+
Version: 1.0
|
|
4
|
+
Summary: An SSL-enabled development server for Django. Supports latest versions of Django and Python
|
|
5
|
+
Author-email: Shashwat <shashwat13.8@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: django-sslserver,sslserver
|
|
8
|
+
Classifier: Environment :: Web Environment
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python
|
|
12
|
+
Classifier: Programming Language :: Python :: 2
|
|
13
|
+
Classifier: Programming Language :: Python :: 2.7
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.4
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.5
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Framework :: Django
|
|
22
|
+
Classifier: Framework :: Django :: 1.8
|
|
23
|
+
Classifier: Framework :: Django :: 1.9
|
|
24
|
+
Classifier: Framework :: Django :: 1.10
|
|
25
|
+
Classifier: Framework :: Django :: 1.11
|
|
26
|
+
Classifier: Framework :: Django :: 2.0
|
|
27
|
+
Classifier: Framework :: Django :: 2.1
|
|
28
|
+
Classifier: Framework :: Django :: 2.2
|
|
29
|
+
Classifier: Framework :: Django :: 4.0
|
|
30
|
+
Classifier: Framework :: Django :: 4.2
|
|
31
|
+
Requires-Python: >=2
|
|
32
|
+
Description-Content-Type: text/x-rst
|
|
33
|
+
License-File: LICENSE
|
|
34
|
+
License-File: AUTHORS
|
|
35
|
+
Requires-Dist: Django>=1.8
|
|
36
|
+
|
|
37
|
+
====================
|
|
38
|
+
Django SSL Server v2
|
|
39
|
+
====================
|
|
40
|
+
|
|
41
|
+
.. image:: https://img.shields.io/pypi/v/django-sslserver-v2.svg
|
|
42
|
+
:target: https://pypi.python.org/pypi/django-sslserver-v2
|
|
43
|
+
|
|
44
|
+
.. image:: https://img.shields.io/pypi/pyversions/django-sslserver-v2.svg
|
|
45
|
+
:target: https://pypi.python.org/pypi/django-sslserver-v2/
|
|
46
|
+
|
|
47
|
+
Django SSL Server v2 is a SSL-enabled development server for the Django Framework, a clone of `django-sslserver
|
|
48
|
+
<https://github.com/teddziuba/django-sslserver>`_. This project is actively maintained and supports the latest version of Django and Python.
|
|
49
|
+
|
|
50
|
+
Please note that this `should not be used for production setups
|
|
51
|
+
<https://docs.djangoproject.com/en/4.2/ref/django-admin/#runserver>`_. This
|
|
52
|
+
app is intended for special use-cases. Most people should instead do a proper
|
|
53
|
+
`production deployment
|
|
54
|
+
<https://docs.djangoproject.com/en/4.2/howto/deployment/>`_ where a real
|
|
55
|
+
webserver such as Apache or NGINX handles SSL.
|
|
56
|
+
|
|
57
|
+
Getting Started
|
|
58
|
+
===============
|
|
59
|
+
|
|
60
|
+
Install the module in your Python distribution or virtualenv::
|
|
61
|
+
|
|
62
|
+
$ pip install django-sslserver-v2
|
|
63
|
+
|
|
64
|
+
Add the application to your `INSTALLED_APPS`::
|
|
65
|
+
|
|
66
|
+
INSTALLED_APPS = (...
|
|
67
|
+
"sslserver",
|
|
68
|
+
...
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
Start a SSL-enabled debug server::
|
|
72
|
+
|
|
73
|
+
$ python manage.py runsslserver
|
|
74
|
+
|
|
75
|
+
and access app on https://localhost:8000 or start server on specified port::
|
|
76
|
+
|
|
77
|
+
$ python manage.py runsslserver 127.0.0.1:9000
|
|
78
|
+
|
|
79
|
+
IPv6 support::
|
|
80
|
+
|
|
81
|
+
$ python manage.py runsslserver -6 [::]:7443
|
|
82
|
+
|
|
83
|
+
You'll now be able to access your Django app on https://localhost:9000/
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
Browser Certificate Errors
|
|
87
|
+
==========================
|
|
88
|
+
|
|
89
|
+
Using the default settings, your local browser will make all sorts of noise that it *doesn't trust the certificate*. **This is expected.**
|
|
90
|
+
|
|
91
|
+
Django SSL Server ships "batteries included" with a self-signed server certificate. With self-signed certificates,
|
|
92
|
+
the server is effectively telling the user, "I'm such-and-such server, because I said so". Whereas, with a commercial
|
|
93
|
+
SSL certificate, the server tells the user, "I'm Bank of America, because VeriSign said so (or any other commercial certificate authority)."
|
|
94
|
+
|
|
95
|
+
There are two options for making the certificate warning go away in development:
|
|
96
|
+
|
|
97
|
+
**Option 1**: Tell your browser to explicitly trust the certificate. You can do this in your browser's "advanced settings"
|
|
98
|
+
tab, by installing ``sslserver/certs/development.crt`` as a trusted certificate. The mechanism for this varies from browser to browser.
|
|
99
|
+
|
|
100
|
+
**Option 2**: Use a certificate from a CA that your browser trusts, for example `Letsencrypt <https://letsencrypt.org>`_.
|
|
101
|
+
If you have a certificate/key pair from a certificate authority,
|
|
102
|
+
you can tell Django SSL Server to use it with the following arguments::
|
|
103
|
+
|
|
104
|
+
$ python manage.py runsslserver --certificate /path/to/certificate.crt --key /path/to/key.key
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
Third-Party Static File Handlers
|
|
108
|
+
================================
|
|
109
|
+
|
|
110
|
+
If you're using a wrapper around your WSGI application such as dj_static or WhiteNoise, you probably want to let it handle serving
|
|
111
|
+
static files. Otherwise, you may see 404s when requesting static files. You can disable the default behavior by using the ``--nostatic``
|
|
112
|
+
option.
|
|
113
|
+
|
|
114
|
+
Getting Involved
|
|
115
|
+
================
|
|
116
|
+
|
|
117
|
+
Feel free to open pull requests or issues. GitHub is the canonical location of this project.
|
|
118
|
+
|
|
119
|
+
Special Thanks
|
|
120
|
+
===============
|
|
121
|
+
Special thanks to `@teddziuba
|
|
122
|
+
<https://github.com/teddziuba>`_ for building `django-sslserver
|
|
123
|
+
<https://github.com/teddziuba/django-sslserver>`_ and all the `contributers
|
|
124
|
+
<https://github.com/shashwat2003/django-sslserver-v2/blob/master/AUTHORS>`_
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
AUTHORS
|
|
2
|
+
LICENSE
|
|
3
|
+
MANIFEST.in
|
|
4
|
+
README.rst
|
|
5
|
+
pyproject.toml
|
|
6
|
+
requirements.txt
|
|
7
|
+
django_sslserver_v2.egg-info/PKG-INFO
|
|
8
|
+
django_sslserver_v2.egg-info/SOURCES.txt
|
|
9
|
+
django_sslserver_v2.egg-info/dependency_links.txt
|
|
10
|
+
django_sslserver_v2.egg-info/requires.txt
|
|
11
|
+
django_sslserver_v2.egg-info/top_level.txt
|
|
12
|
+
sslserver/__init__.py
|
|
13
|
+
sslserver/certs/development.crt
|
|
14
|
+
sslserver/certs/development.key
|
|
15
|
+
sslserver/management/__init__.py
|
|
16
|
+
sslserver/management/commands/__init__.py
|
|
17
|
+
sslserver/management/commands/runsslserver.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Django>=1.8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sslserver
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "django-sslserver-v2"
|
|
7
|
+
authors = [{ name = "Shashwat", email = "shashwat13.8@gmail.com" }]
|
|
8
|
+
description = "An SSL-enabled development server for Django. Supports latest versions of Django and Python"
|
|
9
|
+
requires-python = ">=2"
|
|
10
|
+
keywords = ["django-sslserver", "sslserver"]
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Environment :: Web Environment",
|
|
14
|
+
"License :: OSI Approved :: MIT License",
|
|
15
|
+
"Operating System :: OS Independent",
|
|
16
|
+
"Programming Language :: Python",
|
|
17
|
+
"Programming Language :: Python :: 2",
|
|
18
|
+
"Programming Language :: Python :: 2.7",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.4",
|
|
21
|
+
"Programming Language :: Python :: 3.5",
|
|
22
|
+
"Programming Language :: Python :: 3.6",
|
|
23
|
+
"Programming Language :: Python :: 3.7",
|
|
24
|
+
"Programming Language :: Python :: 3.10",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Framework :: Django",
|
|
27
|
+
"Framework :: Django :: 1.8",
|
|
28
|
+
"Framework :: Django :: 1.9",
|
|
29
|
+
"Framework :: Django :: 1.10",
|
|
30
|
+
"Framework :: Django :: 1.11",
|
|
31
|
+
"Framework :: Django :: 2.0",
|
|
32
|
+
"Framework :: Django :: 2.1",
|
|
33
|
+
"Framework :: Django :: 2.2",
|
|
34
|
+
"Framework :: Django :: 4.0",
|
|
35
|
+
"Framework :: Django :: 4.2",
|
|
36
|
+
]
|
|
37
|
+
dependencies = ["Django >= 1.8"]
|
|
38
|
+
dynamic = ["version", "readme"]
|
|
39
|
+
|
|
40
|
+
# [tool.setuptools]
|
|
41
|
+
# packages = find
|
|
42
|
+
|
|
43
|
+
[tool.setuptools.packages.find]
|
|
44
|
+
where = ["."] # list of folders that contain the packages (["."] by default)
|
|
45
|
+
exclude = [
|
|
46
|
+
"demo",
|
|
47
|
+
] # exclude packages matching these glob patterns (empty by default)
|
|
48
|
+
namespaces = false # to disable scanning PEP 420 namespaces (true by default)
|
|
49
|
+
|
|
50
|
+
[tool.setuptools.dynamic]
|
|
51
|
+
version = { attr = "sslserver.__version__" }
|
|
52
|
+
readme = { file = ["README.rst"] }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
django>=1.8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.0"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
-----BEGIN CERTIFICATE-----
|
|
2
|
+
MIIGSTCCBDGgAwIBAgIJAPc4JnQC+MORMA0GCSqGSIb3DQEBCwUAMIG6MQswCQYD
|
|
3
|
+
VQQGEwJV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JH9wAn6xjFTrVUOIpQ6IpcEZ8WfgCres3IzobzdorlSn0SRC6XB0+Z/yu9
|
|
40
|
+
1kLNX0Ekyhbvf9eGDFBdy9vvh4Jvxv/qQYsP7MkCggEAcMY8cFR30exE35ZJpTJH
|
|
41
|
+
upO67LciCF/9VweX2NJ2TfkW5mw8MYroTisSo7mqFxOxXRy9ghpCxUN46slNoru2
|
|
42
|
+
B7QVsLhGZY4ymoqY4xvyT2PTWyHt+ZBw+hm9lFWxaCATiCWXcxGk0of5EpOGlVNA
|
|
43
|
+
VmDd4JiHr6ntYnVPTLhm84bOUpJKenLMjmNMop57192I6KKVStK/G9exBT9mkpIb
|
|
44
|
+
QoKuKIM48p1232sFkPafdDSbPIGxY1JTmSHanV92NLE8pSsF62dNoz4YBZwnfdln
|
|
45
|
+
cW71ldl8HcCxLntZNYVDpQAB9DSLE+x16cuy7iuyNKyZKtumDPZjkKHu6r4Y8CPv
|
|
46
|
+
uQKCAQEAlkgFgNAsiOtPwFBZ6FW3q/YrlFE+hdhIieIZkS41qxAjgteiRMCANv7B
|
|
47
|
+
SvFO3i4bzwuB3WtxnGSsk+uybb4u+Sju6cwWnYk5plpvG5w2I1i9Udmd+UDCblLy
|
|
48
|
+
zmy12NHMkmQp9VGaFujjbOB/pboIQvocvqPj6FngCwLYPpmx8w0EG9LNCosPFCo6
|
|
49
|
+
6T4413Iadde0g55MpxC7SvOWK08uxBXVksEacGBD1qZ8ghB6CbFoTGymI3Gvj8Wl
|
|
50
|
+
Mm98jE/Xih/zgp8YXe4i7N8wDiV/Jn16Ic5U1uQtfiNhEwBCIyKYeuW/ybaLT8IV
|
|
51
|
+
ywoqq7w2QdhJK/vom01mFY8wglE8lQ==
|
|
52
|
+
-----END PRIVATE KEY-----
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import ssl
|
|
5
|
+
import sys
|
|
6
|
+
|
|
7
|
+
try:
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
except ImportError:
|
|
10
|
+
# removed in django version 3
|
|
11
|
+
from django.utils._os import upath
|
|
12
|
+
|
|
13
|
+
from django.core.servers.basehttp import WSGIRequestHandler
|
|
14
|
+
from django.core.management.base import CommandError
|
|
15
|
+
from django.core.management.commands import runserver
|
|
16
|
+
from django.contrib.staticfiles.handlers import StaticFilesHandler
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
if (sys.version_info[0] > 3) or \
|
|
20
|
+
(sys.version_info[0] == 3 and sys.version_info[1] >= 6) or \
|
|
21
|
+
(sys.version_info[0] == 3 and sys.version_info[1] == 5 and sys.version_info[2] >= 3) or \
|
|
22
|
+
(sys.version_info[0] == 2 and sys.version_info[1] == 7 and sys.version_info[2] >= 13):
|
|
23
|
+
_ssl_version = ssl.PROTOCOL_TLS
|
|
24
|
+
else:
|
|
25
|
+
_ssl_version = ssl.PROTOCOL_SSLv23
|
|
26
|
+
|
|
27
|
+
try:
|
|
28
|
+
from django.core.servers.basehttp import WSGIServerException
|
|
29
|
+
except ImportError:
|
|
30
|
+
from socket import error as WSGIServerException
|
|
31
|
+
|
|
32
|
+
try:
|
|
33
|
+
# introduced in Django 2.0
|
|
34
|
+
from django.core.servers.basehttp import ThreadedWSGIServer
|
|
35
|
+
except ImportError:
|
|
36
|
+
try:
|
|
37
|
+
import socketserver
|
|
38
|
+
except ImportError:
|
|
39
|
+
# Python 2 compatibility
|
|
40
|
+
import SocketServer as socketserver
|
|
41
|
+
from django.core.servers.basehttp import WSGIServer
|
|
42
|
+
|
|
43
|
+
class ThreadedWSGIServer(socketserver.ThreadingMixIn, WSGIServer):
|
|
44
|
+
"""A threaded version of the WSGIServer"""
|
|
45
|
+
pass
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class SecureHTTPServer(ThreadedWSGIServer):
|
|
49
|
+
def __init__(self, address, handler_cls, certificate, key, ipv6=False):
|
|
50
|
+
super(SecureHTTPServer, self).__init__(address, handler_cls, ipv6=ipv6)
|
|
51
|
+
try:
|
|
52
|
+
self.socket = ssl.wrap_socket(self.socket, certfile=certificate,
|
|
53
|
+
keyfile=key, server_side=True,
|
|
54
|
+
ssl_version=_ssl_version,
|
|
55
|
+
cert_reqs=ssl.CERT_NONE)
|
|
56
|
+
except AttributeError:
|
|
57
|
+
# Python 3.12 compatibility
|
|
58
|
+
self.context = ssl.SSLContext(_ssl_version)
|
|
59
|
+
self.context.load_cert_chain(certificate, key)
|
|
60
|
+
self.socket = self.context.wrap_socket(
|
|
61
|
+
self.socket,
|
|
62
|
+
server_side=True,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class WSGIRequestHandler(WSGIRequestHandler):
|
|
67
|
+
def get_environ(self):
|
|
68
|
+
env = super(WSGIRequestHandler, self).get_environ()
|
|
69
|
+
env['HTTPS'] = 'on'
|
|
70
|
+
return env
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def default_ssl_files_dir():
|
|
74
|
+
import sslserver as app_module
|
|
75
|
+
|
|
76
|
+
try:
|
|
77
|
+
ssl_dir = str(Path(app_module.__file__).parent / 'certs')
|
|
78
|
+
except NameError:
|
|
79
|
+
# Django < 3 backwards compatibility
|
|
80
|
+
mod_path = os.path.dirname(upath(app_module.__file__))
|
|
81
|
+
ssl_dir = os.path.join(mod_path, "certs")
|
|
82
|
+
|
|
83
|
+
return ssl_dir
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class Command(runserver.Command):
|
|
87
|
+
def add_arguments(self, parser):
|
|
88
|
+
super(Command, self).add_arguments(parser)
|
|
89
|
+
parser.add_argument("--certificate",
|
|
90
|
+
default=os.path.join(default_ssl_files_dir(),
|
|
91
|
+
"development.crt"),
|
|
92
|
+
help="Path to the certificate"),
|
|
93
|
+
parser.add_argument("--key",
|
|
94
|
+
default=os.path.join(default_ssl_files_dir(),
|
|
95
|
+
"development.key"),
|
|
96
|
+
help="Path to the key file"),
|
|
97
|
+
parser.add_argument("--nostatic", dest='use_static_handler',
|
|
98
|
+
action='store_false', default=None,
|
|
99
|
+
help="Do not use internal static file handler"),
|
|
100
|
+
parser.add_argument("--static", dest='use_static_handler',
|
|
101
|
+
action='store_true',
|
|
102
|
+
help="Use internal static file handler"),
|
|
103
|
+
|
|
104
|
+
help = "Run a Django development server over HTTPS"
|
|
105
|
+
|
|
106
|
+
def get_handler(self, *args, **options):
|
|
107
|
+
"""
|
|
108
|
+
Returns the static files serving handler wrapping the default handler,
|
|
109
|
+
if static files should be served. Otherwise just returns the default
|
|
110
|
+
handler.
|
|
111
|
+
|
|
112
|
+
"""
|
|
113
|
+
handler = super(Command, self).get_handler(*args, **options)
|
|
114
|
+
insecure_serving = options.get('insecure_serving', False)
|
|
115
|
+
if self.should_use_static_handler(options):
|
|
116
|
+
return StaticFilesHandler(handler)
|
|
117
|
+
return handler
|
|
118
|
+
|
|
119
|
+
def should_use_static_handler(self, options):
|
|
120
|
+
# it's a bit weird to import settings in the middle of the method, but
|
|
121
|
+
# this is what inner_run does
|
|
122
|
+
from django.conf import settings
|
|
123
|
+
use_static_handler = options.get('use_static_handler')
|
|
124
|
+
if use_static_handler:
|
|
125
|
+
return True
|
|
126
|
+
if (use_static_handler is None and
|
|
127
|
+
'django.contrib.staticfiles' in settings.INSTALLED_APPS):
|
|
128
|
+
return True
|
|
129
|
+
return False
|
|
130
|
+
|
|
131
|
+
def check_certs(self, key_file, cert_file):
|
|
132
|
+
# TODO: maybe validate these? wrap_socket doesn't...
|
|
133
|
+
|
|
134
|
+
if not os.path.exists(key_file):
|
|
135
|
+
raise CommandError("Can't find key at %s" % key_file)
|
|
136
|
+
if not os.path.exists(cert_file):
|
|
137
|
+
raise CommandError("Can't find certificate at %s" %
|
|
138
|
+
cert_file)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def inner_run(self, *args, **options):
|
|
142
|
+
# Django did a shitty job abstracting this.
|
|
143
|
+
|
|
144
|
+
key_file = options.get("key")
|
|
145
|
+
cert_file = options.get("certificate")
|
|
146
|
+
self.check_certs(key_file, cert_file)
|
|
147
|
+
|
|
148
|
+
from django.conf import settings
|
|
149
|
+
from django.utils import translation
|
|
150
|
+
|
|
151
|
+
threading = options.get('use_threading')
|
|
152
|
+
shutdown_message = options.get('shutdown_message', '')
|
|
153
|
+
quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C'
|
|
154
|
+
|
|
155
|
+
self.stdout.write("Validating models...\n\n")
|
|
156
|
+
self.check(display_num_errors=True)
|
|
157
|
+
self.stdout.write((
|
|
158
|
+
"%(started_at)s\n"
|
|
159
|
+
"Django version %(version)s, using settings %(settings)r\n"
|
|
160
|
+
"Starting development server at https://%(addr)s:%(port)s/\n"
|
|
161
|
+
"Using SSL certificate: %(cert)s\n"
|
|
162
|
+
"Using SSL key: %(key)s\n"
|
|
163
|
+
"Quit the server with %(quit_command)s.\n"
|
|
164
|
+
) % {
|
|
165
|
+
"started_at": datetime.now().strftime('%B %d, %Y - %X'),
|
|
166
|
+
"version": self.get_version(),
|
|
167
|
+
"settings": settings.SETTINGS_MODULE,
|
|
168
|
+
"addr": self._raw_ipv6 and '[%s]' % self.addr or self.addr,
|
|
169
|
+
"port": self.port,
|
|
170
|
+
"quit_command": quit_command,
|
|
171
|
+
"cert": cert_file,
|
|
172
|
+
"key": key_file
|
|
173
|
+
})
|
|
174
|
+
# django.core.management.base forces the locale to en-us. We should
|
|
175
|
+
# set it up correctly for the first request (particularly important
|
|
176
|
+
# in the "--noreload" case).
|
|
177
|
+
translation.activate(settings.LANGUAGE_CODE)
|
|
178
|
+
|
|
179
|
+
try:
|
|
180
|
+
handler = self.get_handler(*args, **options)
|
|
181
|
+
server = SecureHTTPServer((self.addr, int(self.port)),
|
|
182
|
+
WSGIRequestHandler,
|
|
183
|
+
cert_file, key_file, ipv6=self.use_ipv6)
|
|
184
|
+
server.set_app(handler)
|
|
185
|
+
server.serve_forever()
|
|
186
|
+
|
|
187
|
+
except WSGIServerException:
|
|
188
|
+
e = sys.exc_info()[1]
|
|
189
|
+
# Use helpful error messages instead of ugly tracebacks.
|
|
190
|
+
ERRORS = {
|
|
191
|
+
13: "You don't have permission to access that port.",
|
|
192
|
+
98: "That port is already in use.",
|
|
193
|
+
99: "That IP address can't be assigned-to.",
|
|
194
|
+
}
|
|
195
|
+
try:
|
|
196
|
+
error_text = ERRORS[e.args[0].args[0]]
|
|
197
|
+
except (AttributeError, KeyError):
|
|
198
|
+
error_text = str(e)
|
|
199
|
+
self.stderr.write("Error: %s" % error_text)
|
|
200
|
+
# Need to use an OS exit because sys.exit doesn't work in a thread
|
|
201
|
+
os._exit(1)
|
|
202
|
+
except KeyboardInterrupt:
|
|
203
|
+
if shutdown_message:
|
|
204
|
+
self.stdout.write(shutdown_message)
|
|
205
|
+
sys.exit(0)
|
|
206
|
+
|