File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change 1111use OCA \User_LDAP \Exceptions \ConfigurationIssueException ;
1212use OCP \ICache ;
1313use OCP \ICacheFactory ;
14+ use OCP \ICertificateManager ;
1415use OCP \IL10N ;
1516use OCP \Server ;
1617use OCP \Util ;
@@ -686,6 +687,26 @@ private function doConnect($host, $port): bool {
686687 $ this ->ldap ->setOption (null , LDAP_OPT_X_TLS_REQUIRE_CERT , LDAP_OPT_X_TLS_DEMAND );
687688 }
688689
690+ /** @var ICertificateManager $certManager */
691+ $ certManager = Server::get (ICertificateManager::class);
692+ $ defaultCertificatePath = $ certManager ->getDefaultCertificatesBundlePath ();
693+ // We check if default certificate path is actually set to a custom value.
694+ // Otherwise this would be a breaking change and cannot be backported.
695+ if (!empty ($ defaultCertificatePath ) && $ defaultCertificatePath !== \OC ::$ SERVERROOT . '/resources/config/ca-bundle.crt ' ) {
696+ $ absoluteBundlePath = $ certManager ->getAbsoluteBundlePath ();
697+ if ($ this ->ldap ->setOption (null , LDAP_OPT_X_TLS_CACERTFILE , $ absoluteBundlePath )) {
698+ $ this ->logger ->debug (
699+ 'Adjusted the tls certificate file path to ' . $ absoluteBundlePath ,
700+ ['app ' => 'user_ldap ' ]
701+ );
702+ } else {
703+ $ this ->logger ->warning (
704+ 'Could not change the tls certificate file path. ' ,
705+ ['app ' => 'user_ldap ' ]
706+ );
707+ }
708+ }
709+
689710 $ this ->ldapConnectionRes = $ this ->ldap ->connect ($ host , $ port ) ?: null ;
690711
691712 if ($ this ->ldapConnectionRes === null ) {
You can’t perform that action at this time.
0 commit comments