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

Added support to change the TLS_REQCERT option #11

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 9 additions & 0 deletions bin/ssh-ldap-pubkey
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class LdapSSH(object):
if not conf.uri or not conf.base:
raise ConfigError("Base DN and LDAP URI must be provided.", 1)

ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT, conf.tls_required)
if conf.cacert_dir:
# this is a global option!
ldap.set_option(ldap.OPT_X_TLS_CACERTDIR, conf.cacert_dir)
Expand Down Expand Up @@ -206,6 +207,14 @@ class LdapConfig(object):
self.filter = conf.get('pam_filter', DEFAULT_FILTER)
self.cacert_dir = conf.get('tls_cacertdir', None)

self.tls_required = {
'never': ldap.OPT_X_TLS_NEVER,
'allow': ldap.OPT_X_TLS_ALLOW,
'try': ldap.OPT_X_TLS_TRY,
'demand': ldap.OPT_X_TLS_DEMAND,
'hard': ldap.OPT_X_TLS_HARD
}[conf.get('tls_reqcert', 'demand')]

self.scope = {
'base': ldap.SCOPE_BASE,
'one': ldap.SCOPE_ONELEVEL,
Expand Down