【发布时间】:2015-03-20 17:41:34
【问题描述】:
我需要将 Docker 容器连接到公司 LDAP 服务器。
容器的目的是根据公司的 LDAP 服务器对用户进行身份验证。
容器可以在“匿名”模式下完美地查询服务器。问题是当我尝试进行身份验证时。服务器要求对凭据进行保密传输。也就是说,通过 SSL/TLS。
有趣的是,在我的 Ubuntu 主机上,我能够查询服务器并对其进行身份验证。所以,这适用于我的主机,但不适用于容器
ldapsearch -x -D "uid=<ACCOUNT>,ou=People,o=hp.com" -W -H ldaps://<LDAP DOMAIN> -b "o=hp.com" -s sub 'uid=*'
容器可以匿名查询服务器(无需 SSL)。所以这在容器中有效:
ldapsearch -d8 -x -H ldaps://<LDAP DOMAIN> -b "o=hp.com" -s sub 'uid=*'
这样:
curl "ldap://<LDAP DOMAIN>/o=hp.com?cn?sub?(sn=rosado)"
现在,我确定这是 SSL 的问题,因为在容器内部...
1)我可以匿名连接到 LDAP 服务器(因为匿名用户不需要保密通信。因此,他们不需要 SSL)。
2) 我在调试模式下运行 ldapsearch 时得到以下报告:
ldapsearch -x -D "uid=<ACCOUNT>,ou=People,o=hp.com" -W -H ldaps://<LDAP DOMAIN> -b "o=hp.com" -s sub 'uid=*
调试输出:
TLS: can't connect: (unknown error code). ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
我尝试过的一些事情包括:
-将证书从我的主机安装到我的容器。将它放在 /usr/local/share/ca-certificates/ 并执行update-ca-certificates。
-使用容器中的openssl客户端确保可以建立连接openssl s_client -connect <LDAP DOMAIN>:<PORT>。这是输出:
CONNECTED(00000003)
depth=1 O = hp.com, OU = IT Infrastructure, C = US, O = Hewlett-Packard Company, CN = <CORP INFO> Class 2 Certification Authority
verify error:num=19:self signed certificate in certificate chain
verify return:0
---
Certificate chain
<CORP INFO>
---
Server certificate
-----BEGIN CERTIFICATE-----
<CORP INFO>
Start Time: 1426872988
Timeout : 300 (sec)
Verify return code: 19 (self signed certificate in certificate chain)
【问题讨论】:
标签: networking ssl ldap docker containers