Score:0

Can't contact LDAP server with Google WorkspaceLDAP

br flag

I try to test the connection to the Google Workspace LDAP server. I follow this help page: https://support.google.com/a/answer/9190869?hl=en#ldap-query&zippy=%2Cldapsearch

But when I run the suggested commands, I get this error:

root@debian:/etc/freeradius/3.0# LDAPTLS_CERT=/etc/freeradius/3.0/certs/ldap-client.crt LDAPTLS_KEY=/etc/freeradius/3.0/certs/ldap-client.key ldapsearch -v -H ldaps://ldap.google.com:636 -b dc=MYDOMAIN,dc=cz '([email protected])'
ldap_initialize( ldaps://ldap.google.com:636/??base )
ldap_sasl_interactive_bind_s: Can't contact LDAP server (-1)
    additional info: (unknown error code)

Any idea what's wrong?

Score:1
de flag

On Ubuntu 20.04 I found that I had to disable TLS1.3 by setting LDAPTLS_CIPHER_SUITE='NORMAL:!VERS-TLS1.3' to get ldapsearch working against Google LDAP.

How I got here:

The ldapsearch command supports printing increased debug to the console by using the -d debuglevel flag. Debug level 1 (-d1) was enough for me, higher debug levels get very verbose and hard to read.

A simple debug command might look like this:

vagrant@focal:~$ ldapsearch -H ldaps://ldap.google.com:636 -d1

From here I could see that the certificate was untrusted:

...
attempting to connect:
connect success
TLS: peer cert untrusted or revoked (0x42)
TLS: can't connect: (unknown error code).
...

This didn't make any sense. The certificate being returned by ldap.google.com was valid and could be verified against my /etc/ssl/certs/ca-certificates.crt using openssl s_client -connect ldap.google.com:636 -CAfile /etc/ssl/certs/ca-certificates.crt but ldapsearch didn't trust it.

I finally came across this post on the OpenLDAP mailing list which explained the problem was with SNI not being supported which would cause Google to return an invalid self-signed cert. I wasn't able to find a proper fix, but the workaround at the bottom to disable TLS1.3 by setting the LDAPTLS_CIPHER_SUITE environment variable worked for me because my OpenLDAP was using GnuTLS. If you're using OpenSSL you'll likely need to find a different workaround, but the root cause is probably still the same.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.