PHP LDAP verifying certificate - ldap_start_tls (): unable to start TLS

I am trying to authenticate LDAP with a certificate in Ubuntu

My PHP code looks like this:

   $ldap="ldap://myhostname";
   $usr="myemail@domain.com";
   $pwd="mypwd";

   $ds=ldap_connect($ldap);  
   $ldapbind=false;
   if(ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3))
      if(ldap_set_option($ds, LDAP_OPT_REFERRALS, 0)) 
         if(ldap_start_tls($ds)) 
               $ldapbind = @ldap_bind($ds, $usr, $pwd);    
   ldap_close($ds);

   if(!$ldapbind)
      echo "ERROR";
   else
      echo "OK";

      

In my ldap.conf file, I added the following lines:

TLS_REQCERT never

TLS_CACERT / home / Desktop / rootCA.crt

But we output as follows   ldap_start_tls (): cannot start TLS

+3


source to share





All Articles