connect to ldap secure google from php gives error Unable to start TLS

  ldap, php

I’m trying to connect to google.ldap.com in php 7.3 but I get an error: "Warning: ldap_start_tls(): Unable to start TLS: Connect error"

my code:

ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
$ldap = ldap_connect('ldap.google.com');
ldap_set_option(NULL, LDAP_OPT_X_TLS_CERTFILE, "Google_xxxxx.crt");
ldap_set_option(NULL, LDAP_OPT_X_TLS_KEYFILE, "Google_xxxxx.key");
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($ldap, LDAP_OPT_REFERRALS, 0);
ldap_start_tls($ldap);

my cert file and key file are both located in the same folder.

I’m using Xampp on a windows 10 machine.

I have tried to change:

$ldap = ldap_connect('ldap.google.com');

into

$ldap = ldap_connect('ldaps://ldap.google.com',636);

but I still get the same error.

If somebody knows what is wrong with the code, thanks!

Source: Ask PHP

LEAVE A COMMENT