我正在针对活动目录服务器运行 ldapsearch,
使用 ldap 协议可以工作:
ldapsearch -h IP -p 389 -b 'DC=testnet,DC=com' -D 'CN=admin,CN=Users,DC=testnet,DC=com' -w 'XX'
使用 ldaps 协议会失败:
ldapsearch -H ldaps://10.10.10.20:636 -b 'DC=testnet,DC=com' -D 'CN=admin,CN=Users,DC=testnet,DC=com' -w 'XXX'
strace output:
connect(3, {sa_family=AF_INET, sin_port=htons(636), sin_addr=inet_addr("10.10.10.20")}, 16) = 0
ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
从 nmap 来看 389 和 636 端口都是打开的,出了什么问题?
编辑
端口 636 上有可用的证书:
# openssl s_client -connect 10.10.10.20:636 -showcerts
CONNECTED(00000003)
Can't use SSL_get_servername
depth=0 CN = DC-01.testnet.com
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 CN = DC-01.testnet.com
verify error:num=21:unable to verify the first certificate
verify return:1
---
Certificate chain
0 s:CN = DC-01.testnet.com
i:DC = com, DC = testnet, CN = testnet-SRV1-CA
...