在 ldap 主机上更新证书后,centos 6.6 ldap 身份验证不再起作用

在 ldap 主机上更新证书后,centos 6.6 ldap 身份验证不再起作用

我们最近更新了 LDAP 主机上的 CA 证书。有几台 CentOS 5.x 服务器似乎在针对 LDAP 主机进行身份验证时没有任何问题,但有一台 Centos 6.6 服务器却无法进行身份验证。我不知道该服务器最初是如何配置的,系统管理员离开时没有留下太多文档。ldapsearch 客户端似乎可以正常工作。当我使用最详细的调试输出运行 ldapsearch 时,我没有看到任何错误:

$ ldapsearch -h ldap.hostname.com -x -LLL -v -d 167 -s base -b "" 2>&1 | grep -i error

res_errno: 0, res_error: <>, res_matched: <>
res_errno: 0, res_error: <>, res_matched: <>

以下是该实用程序的输出openssl s_client

$ openssl s_client -connect ldap.hostname.com:636 < /dev/null

CONNECTED(00000003)
depth=3 C = SE, O = AddTrust AB, OU = AddTrust External TTP Network, CN = AddTrust External CA Root
verify return:1
depth=2 C = US, ST = New Jersey, L = Jersey City, O = The USERTRUST Network, CN = USERTrust RSA Certification Authority
verify return:1
depth=1 C = US, ST = MI, L = Ann Arbor, O = Internet2, OU = InCommon, CN = InCommon RSA Server CA
verify return:1
depth=0 C = , postalCode = , ST = , L = , street = , O = , OU = , CN = ldap.hostname.com
verify return:1
---
Certificate chain
 0 s:/C=US/postalCode=/ST=/L=/street=/OU=/CN=ldap.hostname.com
   i:/C=US/ST=MI/L=Ann Arbor/O=Internet2/OU=InCommon/CN=InCommon RSA Server CA
 1 s:/C=US/ST=MI/L=Ann Arbor/O=Internet2/OU=InCommon/CN=InCommon RSA Server CA
   i:/C=US/ST=New Jersey/L=Jersey City/O=The USERTRUST Network/CN=USERTrust RSA Certification Authority
 2 s:/C=US/ST=New Jersey/L=Jersey City/O=The USERTRUST Network/CN=USERTrust RSA Certification Authority
   i:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root
 3 s:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root
   i:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root
---
Server certificate
-----BEGIN CERTIFICATE-----
[...]
-----END CERTIFICATE-----
subject=/C=/postalCode=/ST=/L=/street=/O=/OU=/CN=ldap.hostname.com
issuer=/C=US/ST=MI/L=Ann Arbor/O=Internet2/OU=InCommon/CN=InCommon RSA Server CA
---
No client certificate CA names sent
---
SSL handshake has read 5715 bytes and written 607 bytes
---
New, TLSv1/SSLv3, Cipher is AES256-SHA256
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : AES256-SHA256
    Session-ID: [...]
    Session-ID-ctx: 
    Master-Key: [...]
    Key-Arg   : None
    Krb5 Principal: None
    PSK identity: None
    PSK identity hint: None
    Start Time: [...]
    Timeout   : 300 (sec)
    Verify return code: 0 (ok)
---
DONE

当我在调试模式下运行 nslcd 时,发现以下错误:

$ sudo nslcd -d -d -d 2>&1 > nslcd.log

$ cat nslcd.log | grep -i error

res_errno: 0, res_error: <>, res_matched: <>

TLS: cannot open certdb '/etc/openldap/cacerts', error -8018:Unknown PKCS #11 error.

TLS: certificate [...] is not valid - error -8172:Peer's certificate issuer has been marked as not trusted by the user..

TLS: error: connect - force handshake failure: errno 0 - moznss error -8172

TLS: can't connect: TLS error -8172:Peer's certificate issuer has been marked as not trusted by the user..

nslcd: [8b4567] ldap_start_tls_s() failed: Connect error (uri="ldap://ldap.hostname.com/")

nslcd: [8b4567] failed to bind to LDAP server ldap://ldap.hostname.com/: Connect error

res_errno: 0, res_error: <>, res_matched: <>

[...]

以下是 的内容/etc/ldap.conf

base o=org
timelimit 120
bind_timelimit 120
idle_timelimit 3600
nss_initgroups_ignoreusers root,ldap,named,avahi,haldaemon,dbus,radvd,tomcat,radiusd,news,mailman,nscd,gdm
nss_map_attribute uniqueMember member
nss_base_passwd ou=People,?one
nss_base_group ou=Group,?one
tls_cert
tls_key
uri ldap://ldap.hostname.com
ssl start_tls
TLS_CACERTDIR /etc/openldap/certs
pam_password md5
SUDOERS_BASE ou=SUDOers,o=org

以下是 的内容/etc/openldap/ldap.conf

TLS_CACERTDIR /etc/openldap/certs
URI ldap://ldap.hostname.com/
BASE o=org

以下是 的内容/etc/nslcd.conf

uid nslcd
gid ldap
uri ldap://ldap.hostname.com/
base o=org
ssl start_tls
tls_cacertdir /etc/openldap/cacerts
tls_cacertfile /etc/openldap/cacerts/authconfig_downloaded.pem

我已经在 Google 上搜索了错误消息,但网上找到的各种 LDAP 文档让我应接不暇。如能提供任何建议,我将不胜感激。

答案1

对于 rhel 和自版本 6 以来的衍生版本,您可以使用 update-ca-trust(man 8 update-ca-trust 了解所有详细信息)。https://www.happyassassin.net/2015/01/14/trusting-additional-cas-in-fedora-rhel-centos-dont-append-to-etcpkitlscertsca-bundle-crt-or-etcpkitlscert-pem/

基本上,您将 PEM 格式的 ca 文件放在 /etc/pki/ca-trust/source/anchors/ 中,然后以 root 身份运行 update-ca-trust;如果它采用扩展受信任证书格式,那么您应该将其放在 /etc/pki/ca-trust/source 中,然后再次运行 update-ca-trust。

o,并且在 centos 6 中不鼓励运行 nslcd。sssd 在缓存信息等方面做得更好。

相关内容