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

[server] Verify TLS certificate in LDAPS connections #3083

Merged
merged 4 commits into from
Jan 11, 2021

Conversation

jimis
Copy link
Contributor

@jimis jimis commented Dec 8, 2020

If LDAP authentication is used in the server and the LDAP server
connection is using LDAPS, then reject the connection if the certificate
is not trusted by the system.

This can be overriden by setting the environment variable
LDAPTLS_REQCERT=never just like in the ldapsearch command.

NOTE: The option used before to skip the SSL certificate verification
was OPT_X_TLS_ALLOW, which is documented in python-ldap as "used
internally by slapd server". Thus the one used now is OPT_X_TLS_NEVER.

Resolves #3082

@jimis jimis force-pushed the ldaps_fix_cert_verify-gh3082 branch from 96cb08f to cc8eb8d Compare December 28, 2020 19:24
@jimis jimis requested review from bruntib and dkrupp as code owners December 28, 2020 19:24
@jimis
Copy link
Contributor Author

jimis commented Dec 28, 2020

Rebased and pushed update according to my comment above (default behaviour is secure, compatibility is broken). I also fixed an irrelevant typo that kind of proves my point: the LDAP module is not widely used yet, so it's better to break compatibility at this early stage and enforce secure LDAPS connections by default.

Please let me know what you think. Do you prefer insecure default behaviour by default?

If the certificate verification fails while attempting to connect to an
LDAPS server, then the ldap library returns the misleading error type
SERVER_DOWN with unhelpful details:

{'desc': "Can't contact LDAP server", 'info': '(unknown error code)'}

We now print a more relevant message.
@jimis jimis force-pushed the ldaps_fix_cert_verify-gh3082 branch from cc8eb8d to a2eb955 Compare December 29, 2020 07:38
Copy link
Contributor

@csordasmarton csordasmarton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have just some tiny comments otherwise LGTM!

web/server/codechecker_server/auth/cc_ldap.py Show resolved Hide resolved
docs/web/authentication.md Outdated Show resolved Hide resolved
docs/web/authentication.md Outdated Show resolved Hide resolved
jimis added 2 commits January 9, 2021 08:00
If LDAP authentication is used in the server and the LDAP server
connection is using LDAPS, then reject the connection if the certificate
is not trusted by the system.

This can be overriden by setting the
tls_require_cert="never" in the configuration.

NOTE: The option used before to skip the SSL certificate verification
was OPT_X_TLS_ALLOW, which is documented in python-ldap as "used
internally by slapd server". Therefore it was replaced by
OPT_X_TLS_NEVER.
This option does not look like it ever worked because of this small typo.
@jimis jimis force-pushed the ldaps_fix_cert_verify-gh3082 branch from a2eb955 to 7f8119e Compare January 9, 2021 07:00
@jimis
Copy link
Contributor Author

jimis commented Jan 9, 2021

Updated, thanks for the review.

Copy link
Contributor

@csordasmarton csordasmarton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you for this patch 😊

@csordasmarton csordasmarton added this to the release 6.16.0 milestone Jan 11, 2021
@csordasmarton csordasmarton merged commit 7355cd4 into Ericsson:master Jan 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CodeChecker server connects to untrusted LDAPS server for authentication
2 participants