Skip to content

Commit 04f6777

Browse files
committed
feat(ldap): Allow to use global default_certificates_bundle_path for ldap
Signed-off-by: Simon L. <szaimen@e.mail.de>
1 parent 594d220 commit 04f6777

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

apps/user_ldap/lib/Connection.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,26 @@ 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+
/** @var ICertificateManager $certManager */
690+
$certManager = Server::get(ICertificateManager::class);
691+
$defaultCertificatePath = $certManager->getDefaultCertificatesBundlePath();
692+
// We check if default certificate path is actually set to a custom value.
693+
// Otherwise this would be a breaking change and cannot be backported.
694+
if (!empty($defaultCertificatePath) && $defaultCertificatePath !== \OC::$SERVERROOT . '/resources/config/ca-bundle.crt') {
695+
$absoluteBundlePath = $certManager->getAbsoluteBundlePath();
696+
if ($this->ldap->setOption(null, LDAP_OPT_X_TLS_CACERTFILE, $absoluteBundlePath)) {
697+
$this->logger->debug(
698+
'Adjusted the tls certificate file path to ' . $absoluteBundlePath,
699+
['app' => 'user_ldap']
700+
);
701+
} else {
702+
$this->logger->warning(
703+
'Could not change the tls certificate file path.',
704+
['app' => 'user_ldap']
705+
);
706+
}
707+
}
708+
689709
$this->ldapConnectionRes = $this->ldap->connect($host, $port) ?: null;
690710

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

0 commit comments

Comments
 (0)