-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e46d6d7
commit ce50b50
Showing
12 changed files
with
442 additions
and
368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,6 @@ | ||
FROM jazzdd/alpine-flask:python3 | ||
FROM unit:1.31.1-python3.11 | ||
LABEL maintainer="David Wittman" | ||
|
||
RUN apk add --no-cache \ | ||
gcc \ | ||
python3-dev \ | ||
musl-dev \ | ||
libffi-dev \ | ||
openssl \ | ||
openssl-dev | ||
|
||
ADD . /app/ | ||
|
||
RUN export CRYPTOGRAPHY_DONT_BUILD_RUST=1 && \ | ||
pip install -r requirements.txt && \ | ||
apk del gcc git python3-dev musl-dev libffi-dev openssl-dev | ||
EXPOSE 8080 | ||
COPY config.json /docker-entrypoint.d/config.json | ||
COPY . /www/ | ||
RUN pip install -r /www/requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"listeners": { | ||
"*:8080": { | ||
"pass": "applications/flask" | ||
} | ||
}, | ||
"applications": { | ||
"flask": { | ||
"type": "python", | ||
"path": "/www/", | ||
"module": "app", | ||
"callable": "app" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
csr.py | ||
CSR Generator for csrgenerator.com | ||
Copyright (c) 2022 David Wittman <[email protected]> | ||
Copyright (c) 2024 David Wittman <[email protected]> | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
|
@@ -33,11 +33,24 @@ class CsrGenerator(object): | |
def __init__(self, form_values): | ||
self.csr_info = self._validate(form_values) | ||
key_size = self.csr_info.pop('keySize') | ||
|
||
if 'subjectAltNames' in self.csr_info: | ||
# The SAN list should contain the CN as well | ||
# TODO(dw): do list(set()) | ||
sans = f"{self.csr_info['CN']},{self.csr_info.pop('subjectAltNames')}" | ||
else: | ||
sans = self.csr_info['CN'] | ||
if sans.count('.') == 1: | ||
# root domain, add www. as well | ||
sans += ",www.{}".format(sans) | ||
|
||
self.subjectAltNames = list(map(lambda d: "DNS:{}".format(d.strip()), sans.split(','))) | ||
|
||
self.keypair = self.generate_rsa_keypair(key_size) | ||
|
||
def _validate(self, form_values): | ||
valid = {} | ||
fields = ('C', 'ST', 'L', 'O', 'OU', 'CN', 'keySize') | ||
fields = ('C', 'ST', 'L', 'O', 'OU', 'CN', 'keySize', 'subjectAltNames') | ||
required = ('CN',) | ||
|
||
for field in fields: | ||
|
@@ -82,6 +95,13 @@ def csr(self): | |
for (k, v) in self.csr_info.items(): | ||
setattr(subject, k, v) | ||
|
||
request.add_extensions([ | ||
crypt.X509Extension( | ||
"subjectAltName".encode('utf8'), | ||
False, | ||
", ".join(self.subjectAltNames).encode('utf8') | ||
) | ||
]) | ||
request.set_pubkey(self.keypair) | ||
request.sign(self.keypair, self.DIGEST) | ||
return crypt.dump_certificate_request(crypt.FILETYPE_PEM, request) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,24 @@ | ||
-r requirements.txt | ||
# | ||
# These requirements were autogenerated by pipenv | ||
# To regenerate from the project's Pipfile, run: | ||
# | ||
# pipenv lock --requirements --dev-only | ||
# | ||
|
||
-i https://pypi.org/simple | ||
flake8==4.0.1 | ||
mccabe==0.6.1 | ||
nose==1.3.7 | ||
pycodestyle==2.8.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' | ||
pyflakes==2.4.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' | ||
exceptiongroup==1.2.0; python_version < '3.11' | ||
flake8==7.0.0; python_full_version >= '3.8.1' | ||
iniconfig==2.0.0; python_version >= '3.7' | ||
mccabe==0.7.0; python_version >= '3.6' | ||
packaging==23.2; python_version >= '3.7' | ||
pluggy==1.3.0; python_version >= '3.8' | ||
pycodestyle==2.11.1; python_version >= '3.8' | ||
pyflakes==3.2.0; python_version >= '3.8' | ||
pytest==7.4.4; python_version >= '3.7' | ||
tomli==2.0.1; python_version < '3.11' | ||
blinker==1.7.0; python_version >= '3.8' | ||
cffi==1.16.0; python_version >= '3.8' | ||
click==8.1.7; python_version >= '3.7' | ||
cryptography==41.0.7; python_version >= '3.7' | ||
flask==3.0.0; python_version >= '3.8' | ||
importlib-metadata==7.0.1; python_version < '3.10' | ||
itsdangerous==2.1.2; python_version >= '3.7' | ||
jinja2==3.1.2; python_version >= '3.7' | ||
markupsafe==2.1.3; python_version >= '3.7' | ||
pycparser==2.21 | ||
pyopenssl==23.2.0; python_version >= '3.6' | ||
werkzeug==3.0.1; python_version >= '3.8' | ||
zipp==3.17.0; python_version >= '3.8' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,14 @@ | ||
# | ||
# These requirements were autogenerated by pipenv | ||
# To regenerate from the project's Pipfile, run: | ||
# | ||
# pipenv lock --requirements | ||
# | ||
|
||
-i https://pypi.org/simple | ||
cffi==1.15.0 | ||
click==8.0.3; python_version >= '3.6' | ||
cryptography==36.0.1; python_version >= '3.6' | ||
flask==2.0.2 | ||
gunicorn==20.1.0 | ||
itsdangerous==2.0.1; python_version >= '3.6' | ||
jinja2==3.0.3; python_version >= '3.6' | ||
markupsafe==2.0.1; python_version >= '3.6' | ||
blinker==1.7.0; python_version >= '3.8' | ||
cffi==1.16.0; python_version >= '3.8' | ||
click==8.1.7; python_version >= '3.7' | ||
cryptography==41.0.7; python_version >= '3.7' | ||
flask==3.0.0; python_version >= '3.8' | ||
importlib-metadata==7.0.1; python_version < '3.10' | ||
itsdangerous==2.1.2; python_version >= '3.7' | ||
jinja2==3.1.2; python_version >= '3.7' | ||
markupsafe==2.1.3; python_version >= '3.7' | ||
pycparser==2.21 | ||
pyopenssl==21.0.0 | ||
setuptools==60.3.1; python_version >= '3.7' | ||
six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3' | ||
werkzeug==2.0.2; python_version >= '3.6' | ||
pyopenssl==23.2.0; python_version >= '3.6' | ||
werkzeug==3.0.1; python_version >= '3.8' | ||
zipp==3.17.0; python_version >= '3.8' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.