Skip to content

Instantly share code, notes, and snippets.

@mrballcb
Created September 9, 2013 20:58
Show Gist options
  • Save mrballcb/6501428 to your computer and use it in GitHub Desktop.
Save mrballcb/6501428 to your computer and use it in GitHub Desktop.
Setting ldap_require_cert overrides uri parsing to determine TLS options.
diff --git a/src/src/lookups/ldap.c b/src/src/lookups/ldap.c
index f121bce..8c11587 100644
--- a/src/src/lookups/ldap.c
+++ b/src/src/lookups/ldap.c
@@ -416,6 +416,29 @@ if (lcp == NULL)
if (!ldapi)
{
int tls_option;
+ #ifdef LDAP_OPT_X_TLS_REQUIRE_CERT
+ if (eldap_require_cert != NULL)
+ {
+ tls_option = LDAP_OPT_X_TLS_NEVER;
+ if (Ustrcmp(eldap_require_cert, "hard") == 0)
+ {
+ tls_option = LDAP_OPT_X_TLS_HARD;
+ }
+ else if (Ustrcmp(eldap_require_cert, "demand") == 0)
+ {
+ tls_option = LDAP_OPT_X_TLS_DEMAND;
+ }
+ else if (Ustrcmp(eldap_require_cert, "allow") == 0)
+ {
+ tls_option = LDAP_OPT_X_TLS_ALLOW;
+ }
+ else if (Ustrcmp(eldap_require_cert, "try") == 0)
+ {
+ tls_option = LDAP_OPT_X_TLS_TRY;
+ }
+ }
+ else
+ #endif
if (strncmp(ludp->lud_scheme, "ldaps", 5) == 0)
{
tls_option = LDAP_OPT_X_TLS_HARD;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment