$ echo LDAPRC/tmp/ldaprc$ cat /tmp/ldaprcTLS_CACERT /tmp/ca.cert# TLS_REQCERT allow$ ldapsearch -H ldaps://dc1.example.com -x -W -D "ldapbind@example.com" -b "dc=example,dc=com" -d8 "(sAMAccountName=ldapbind)"Enter LDAP Password: TLS: during handshake: peer cert is valid, or was ignored if verification disabled (-9841)TLS: during handshake: Peer certificate is not trusted: kSecTrustResultRecoverableTrustFailureTLS: can't connect: SSLHandshake() failed: misc. bad certificate (-9825).ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
$ openssl s_client -showcerts -connect dc1.example.com:636 -CAfile /tmp/ca.certCONNECTED(00000005)depth=1 O = Samba Administration, OU = Samba - temporary autogenerated CA certificate, CN = DC1.example.comverify return:1depth=0 O = Samba Administration, OU = Samba - temporary autogenerated HOST certificate, CN = DC1.example.comverify return:1---Certificate chain 0 s:/O=Samba Administration/OU=Samba - temporary autogenerated HOST certificate/CN=DC1.example.com i:/O=Samba Administration/OU=Samba - temporary autogenerated CA certificate/CN=DC1.example.com...SSL-Session: Protocol : TLSv1.2 Cipher : ECDHE-RSA-AES256-GCM-SHA384 Session-ID: 859F9D207D57BFC43E14F695CCAC765D588D9E95E694CB7C917F9AD8EE22D717 Session-ID-ctx: Master-Key: 01573B84ED6CFCF83D6E865600EA1ECBB547674A74752CC61208DCBB33D6CBA3F01F1AFB257504EFC006838BB4E7A599 Start Time: 1562867827 Timeout : 7200 (sec) Verify return code: 0 (ok)---^C
setenv LDAPTLS_REQCERT neverldapsearch ...
/usr/local/share/certs/ca-root-nss.crt
setenv TLS_CACERTDIR /path/to/ca.crtldapsearch -x -b "cn=users,dc=ds,dc=example,dc=com" -W -D "cn=binduser,cn=users,dc=ds,dc=example,dc=com" -H ldaps://<myldapserver> -vvv