如何配置 sssd 使用客户端证书/SASL EXTERNAL 对 LDAP 进行身份验证

如何配置 sssd 使用客户端证书/SASL EXTERNAL 对 LDAP 进行身份验证

我需要使用 sssd 针对 389ds 服务器配置各种 Ubuntu Trusty 机器,该服务器需要使用通过客户端证书映射自动选择的 binddn 进行绑定。

我已成功设置 389ds 和 certmap,如下所示:

# By default, we trust any valid certificate that has an ou attribute that
# matches an entry (currently ou=Servers) in the DIT
certmap default     default
default:DNComps
default:FilterComps ou
default:verifycert  off

此外,我还禁用了匿名绑定并强制 SASL 外部绑定,如下所示:

# disable anonymous binds
dn: cn=config
changetype: modify
replace: nsslapd-allow-anonymous-access
nsslapd-allow-anonymous-access: off

# force sasl external binds to use cert
dn: cn=config
changetype: modify
replace: nsslapd-force-sasl-external
nsslapd-force-sasl-external: on

在 sssd 端,我有 /etc/sssd/sssd.conf,如下所示:

[sssd]
config_file_version = 2
domains = LDAP
services = nss, pam

[nss]
filter_groups = root
filter_users = root
reconnection_retries = 3
entry_cache_timeout = 300
entry_cache_nowait_percentage = 75

[pam]
reconnection_retries = 3
offline_credentials_expiration = 2
offline_failed_login_attempts = 3
offline_failed_login_delay = 5

# A native LDAP domain
[domain/LDAP]
enumerate = true
cache_credentials = TRUE
debug_level = 9

id_provider = ldap
auth_provider = ldap
chpass_provider = ldap

ldap_uri = ldaps://ldap.example.com:636
ldap_user_search_base = dc=example,dc=com
tls_reqcert = demand
ldap_tls_cacert = /etc/ssl/certs/root-ca.crt
ldap_tls_cert = /etc/ssl/certs/my.crt
ldap_tls_key = /etc/ssl/private/my.key
ldap_sasl_mech = EXTERNAL

当我启动 sssd 时,sssd 尝试绑定到 389ds,首先尝试匿名绑定(然后失败),然后使用 SASL EXTERNAL 机制(也失败):

(Thu Mar 17 16:08:34 2016) [sssd[be[LDAP]]] [sdap_process_message] (0x4000): Message type: [LDAP_RES_SEARCH_RESULT]
(Thu Mar 17 16:08:34 2016) [sssd[be[LDAP]]] [sdap_get_generic_ext_done] (0x0400): Search result: Inappropriate authentication(48), Anonymous access is not allowed.
(Thu Mar 17 16:08:34 2016) [sssd[be[LDAP]]] [sdap_get_generic_ext_done] (0x0040): Unexpected result from ldap: Inappropriate authentication(48), Anonymous access is not allowed.
(Thu Mar 17 16:08:34 2016) [sssd[be[LDAP]]] [sdap_get_generic_done] (0x0100): sdap_get_generic_ext_recv failed [5]: Input/output error
(Thu Mar 17 16:08:34 2016) [sssd[be[LDAP]]] [sdap_get_server_opts_from_rootdse] (0x0200): No known USN scheme is supported by this server!
(Thu Mar 17 16:08:34 2016) [sssd[be[LDAP]]] [sdap_cli_auth_step] (0x0100): expire timeout is 900
(Thu Mar 17 16:08:34 2016) [sssd[be[LDAP]]] [sdap_cli_auth_step] (0x1000): the connection will expire at 1458231814
(Thu Mar 17 16:08:34 2016) [sssd[be[LDAP]]] [sasl_bind_send] (0x0100): Executing sasl bind mech: EXTERNAL, user: (null)
(Thu Mar 17 16:08:34 2016) [sssd[be[LDAP]]] [sasl_bind_send] (0x0020): ldap_sasl_bind failed (-6)[Unknown authentication method]
(Thu Mar 17 16:08:34 2016) [sssd[be[LDAP]]] [sasl_bind_send] (0x0080): Extended failure message: [SASL(-4): no mechanism available: ]

使用 ssldump,似乎客户端发送了客户端证书,但是 ssldump -A 选项有缺陷,它拒绝告诉我有关此证书的任何信息:

1 3  0.0283 (0.0218)  C>SV3.3(7)  Handshake
      Certificate

我的问题是:

  • 为什么 sssd 尝试匿名绑定会失败?理论上,“nsslapd-force-sasl-external: on”应该会导致所有绑定尝试都被忽略,转而使用客户端证书。

  • 为什么 ssd 尝试使用 SASL/EXTERNAL 绑定失败?

  • 是否有任何指南或方法描述 sssd+ldap 以及客户端证书?

为避免疑问,在这种情况下,简单绑定不是一种选择。

更新:

当我尝试使用 openssl s_client 使用正确的客户端证书连接到 389ds 服务器时,389ds 日志中正确出现以下内容,表明客户端证书触发了成功绑定:

[17/Mar/2016:16:35:02 +0000] conn=130 SSL 128-bit AES-GCM; client CN=stuff,OU=Servers,O=Example,DC=example,DC=com; issuer CN=morestuff,OU=Example Signing CA,O=Example,DC=example,DC=com
[17/Mar/2016:16:35:02 +0000] conn=130 SSL client bound as ou=Servers,dc=example,dc=com

在这种情况下,sssd 似乎没有尝试使用提供的证书和密钥进行绑定。有人知道为什么吗?

答案1

匿名访问的推荐设置(由 RedHat 提供)是将 nsslapd-allow-anonymous-access 设置为“rootdse”,而不是“off”。我很好奇这是否能解决您看到的问题。此设置允许匿名客户端读取服务器配置,但不允许读取目录数据(例如用户)。这在 RedHat Enterprise Linux 7 Linux 域身份、身份验证和策略指南第 412 页。

# force sasl external binds to use cert
dn: cn=config
changetype: modify
replace: nsslapd-force-sasl-external
nsslapd-force-sasl-external: rootdse

答案2

这应该可以回答您关于 sssd 不尝试使用客户端证书的最后一个问题。来自 sssd-ldap,版本 1.1.14(https://jhrozek.fedorapeople.org/sssd/1.14.2/man/sssd-ldap.5.html):

ldap_default_authtok_type (字符串)

The type of the authentication token of the default bind DN.

The two mechanisms currently supported are:

password

obfuscated_password

Default: password

ldap_sasl_mech (字符串)

Specify the SASL mechanism to use. Currently only GSSAPI is tested and supported.

Default: not set

我听到有传言说此功能将包含在 1.1.13 中,但手册页并未提及这方面的任何新内容。

相关内容