Skip to content

Commit decac34

Browse files
committed
feat(ldap): Allow to use global default_certificates_bundle_path for ldap
Signed-off-by: Simon L. <[email protected]>
1 parent 594d220 commit decac34

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

apps/user_ldap/lib/Connection.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,24 @@ private function doConnect($host, $port): bool {
686686
$this->ldap->setOption(null, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_DEMAND);
687687
}
688688

689+
$absoluteBundlePath = \OCP\ICertificateManager::getAbsoluteBundlePath;
690+
$defaultCertificatePath = \OCP\ICertificateManager::getDefaultCertificatesBundlePath;
691+
// We check if default certificate path is actually set to a custom value.
692+
// Otherwise this would be a breaking change and cannot be backported.
693+
if (!empty($defaultCertificatePath) && $defaultCertificatePath !== \OC::$SERVERROOT . '/resources/config/ca-bundle.crt') {
694+
if ($this->ldap->setOption(null, LDAP_OPT_X_TLS_CACERTFILE, $absoluteBundlePath)) {
695+
$this->logger->debug(
696+
'Adjusted the tls certificate file path to ' . $absoluteBundlePath,
697+
['app' => 'user_ldap']
698+
);
699+
} else {
700+
$this->logger->warning(
701+
'Could not change the tls certificate file path.',
702+
['app' => 'user_ldap']
703+
);
704+
}
705+
}
706+
689707
$this->ldapConnectionRes = $this->ldap->connect($host, $port) ?: null;
690708

691709
if ($this->ldapConnectionRes === null) {

0 commit comments

Comments
 (0)