Skip to content

Commit

Permalink
Merge pull request #97 from icgood/env
Browse files Browse the repository at this point in the history
Add environment variables for cert and key files
  • Loading branch information
icgood committed Sep 24, 2020
2 parents 4503095 + bbbd0cb commit 9d0a548
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions docker/Dockerfile
Expand Up @@ -9,3 +9,4 @@ RUN apk --update add --virtual build-dependencies python3-dev build-base \
&& apk del build-dependencies

ENTRYPOINT ["pymap"]
CMD ["--help"]
10 changes: 8 additions & 2 deletions pymap/config.py
Expand Up @@ -203,8 +203,14 @@ def _get_cpu_subsystem(cls) -> Subsystem:

@classmethod
def _load_certs(cls, extra: Mapping[str, Any]) -> SSLContext:
cert_file: Optional[str] = extra.get('cert_file')
key_file: Optional[str] = extra.get('key_file')
try:
cert_file: Optional[str] = os.environ['CERT_FILE']
except KeyError:
cert_file = extra.get('cert_file')
try:
key_file: Optional[str] = os.environ['KEY_FILE']
except KeyError:
key_file = extra.get('key_file')
ssl_context = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
if cert_file is not None:
ssl_context.load_cert_chain(cert_file, key_file)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -28,7 +28,7 @@
license = f.read()

setup(name='pymap',
version='0.20.2',
version='0.20.3',
author='Ian Good',
author_email='ian@icgood.net',
description='Lightweight, asynchronous IMAP serving in Python.',
Expand Down

0 comments on commit 9d0a548

Please sign in to comment.