Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support CA cert file by setting an env variable #83

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ To install and configure the reference implementation, perform the following ste
```
docker build -t nginx-ldap-auth-daemon --build-arg PYTHON_VERSION=3 .
```
If you want to use a CA certification file for validating the LDAP authentication server when using TLS, you can set the `LDAP_CA_CERT` environment variable in the environment running the authentication daemon. With the Docker container, you can do:
```
docker run -e LDAP_CA_CERT='/path/to/cacert/file' nginx-ldap-auth-daemon
```

- **nginx-ldap-auth-daemon-ctl.sh** – Sample shell script for starting and stopping the daemon. Install on the same host as the ldap-auth daemon.

Expand Down
4 changes: 4 additions & 0 deletions nginx-ldap-auth-daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ def do_GET(self):
# Establish a STARTTLS connection if required by the
# headers.
if ctx['starttls'] == 'true':
cacert_file = os.getenv("LDAP_CA_CERT")
if cacert_file:
ldap_obj.set_option(ldap.OPT_X_TLS_CACERTFILE, cacert_file)
ldap_obj.set_option(ldap.OPT_X_TLS_NEWCTX, 0)
ldap_obj.start_tls_s()

# See https://www.python-ldap.org/en/latest/faq.html
Expand Down