From 75b7af9cefba647ae99b8e194adbbe2b4dd173d4 Mon Sep 17 00:00:00 2001 From: Shamil Ganiev Date: Mon, 1 Sep 2025 14:39:42 +0300 Subject: [PATCH] fix: apply workaround for plain ldap connections Signed-off-by: Shamil Ganiev --- .../src/ldap/client.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/plugins/catalog-backend-module-ldap/src/ldap/client.ts b/plugins/catalog-backend-module-ldap/src/ldap/client.ts index 096a501b16..703387f5fe 100644 --- a/plugins/catalog-backend-module-ldap/src/ldap/client.ts +++ b/plugins/catalog-backend-module-ldap/src/ldap/client.ts @@ -56,13 +56,15 @@ export class LdapClient { key: key, }); } - + const tlsOptions: tlsLib.ConnectionOptions = { + secureContext, + rejectUnauthorized: tls?.rejectUnauthorized, + }; const client = new Client({ url: target, - tlsOptions: { - secureContext, - rejectUnauthorized: tls?.rejectUnauthorized, - }, + ...(Object.values(tlsOptions).some(v => v !== undefined) + ? { tlsOptions } + : undefined), }); const ldapClient = new LdapClient(client, logger); @@ -72,7 +74,10 @@ export class LdapClient { await client.bind(bind.dn, bind.secret); } catch (error) { await client.unbind(); - throw new ForwardedError(`LDAP bind failed for ${bind.dn}, ${error}`, error); + throw new ForwardedError( + `LDAP bind failed for ${bind.dn}, ${error}`, + error, + ); } } return ldapClient;