Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix: validate client certificate and key pairing for mTLS in LDAP configuration

Victor Hugo dos Santos0fdec369f582
diff --git a/backend/src/ee/services/ldap-config/ldap-config-service.ts b/backend/src/ee/services/ldap-config/ldap-config-service.ts
index 26605441e0..ed8339b707 100644
--- a/backend/src/ee/services/ldap-config/ldap-config-service.ts
+++ b/backend/src/ee/services/ldap-config/ldap-config-service.ts
@@ -885,6 +885,12 @@ export const ldapConfigServiceFactory = ({
message: "Failed to test LDAP connection due to plan restriction. Upgrade plan to test the LDAP connection."
});
+ if (Boolean(clientCertificate) !== Boolean(clientKeyCertificate)) {
+ throw new BadRequestError({
+ message: "clientCertificate and clientKeyCertificate must be provided together for mTLS."
+ });
+ }
+
return testLDAPConfig({
bindDN,
bindPass,
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/LDAPModal.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/LDAPModal.tsx
index 958487d718..448501410c 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/LDAPModal.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgSsoTab/LDAPModal.tsx
@@ -194,6 +194,14 @@ export const LDAPModal = ({ popUp, handlePopUpClose, handlePopUpToggle, hideDele
};
const handleTestLDAPConnection = async () => {
+ if (Boolean(watchClientCertificate?.trim()) !== Boolean(watchClientKeyCertificate?.trim())) {
+ createNotification({
+ text: "Client Certificate and Client Private Key must be provided together for mTLS.",
+ type: "error"
+ });
+ return;
+ }
+
const isConnected = await testLDAPConnection({
url: watchUrl,
bindDN: watchBindDN,