Linux

Ubuntu 14.04,OpenLDAP TLS 問題

  • May 11, 2020

我在這裡使用本指南設置了一個 openldap 伺服器。它工作得很好。但由於我想使用 sssd,我還需要 TLS 才能為 LDAP 工作。我查看並遵循了指南的TLS部分。

我從來沒有遇到任何錯誤,slapd 又開始正常了。

但。當我嘗試通過 TLS 使用 LDAP 時,它似乎不起作用。

root@server:~# ldapsearch -x -ZZ -H ldap://83.209.243.253 -b dc=daladevelop,dc=se
ldap_start_tls: Protocol error (2)
   additional info: unsupported extended operation

將調試級別提高一些等級會返回更多資訊:

root@server:~# ldapsearch -x -ZZ -H ldap://83.209.243.253 -b dc=daladevelop,dc=se -d 5
ldap_url_parse_ext(ldap://83.209.243.253)
ldap_create
ldap_url_parse_ext(ldap://83.209.243.253:389/??base)
ldap_extended_operation_s
ldap_extended_operation
ldap_send_initial_request
ldap_new_connection 1 1 0
ldap_int_open_connection
ldap_connect_to_host: TCP 83.209.243.253:389
ldap_new_socket: 3
ldap_prepare_socket: 3
ldap_connect_to_host: Trying 83.209.243.253:389
ldap_pvt_connect: fd: 3 tm: -1 async: 0
ldap_open_defconn: successful
ldap_send_server_request
ber_scanf fmt ({it) ber:
ber_scanf fmt ({) ber:
ber_flush2: 31 bytes to sd 3
ldap_result ld 0x7f25df51e220 msgid 1
wait4msg ld 0x7f25df51e220 msgid 1 (infinite timeout)
wait4msg continue ld 0x7f25df51e220 msgid 1 all 1
** ld 0x7f25df51e220 Connections:
* host: 83.209.243.253  port: 389  (default)
 refcnt: 2  status: Connected
 last used: Fri Jun  6 08:52:16 2014


** ld 0x7f25df51e220 Outstanding Requests:
* msgid 1,  origid 1, status InProgress
  outstanding referrals 0, parent count 0
 ld 0x7f25df51e220 request count 1 (abandoned 0)
** ld 0x7f25df51e220 Response Queue:
  Empty
 ld 0x7f25df51e220 response count 0
ldap_chkResponseList ld 0x7f25df51e220 msgid 1 all 1
ldap_chkResponseList returns ld 0x7f25df51e220 NULL
ldap_int_select
read1msg: ld 0x7f25df51e220 msgid 1 all 1
ber_get_next
ber_get_next: tag 0x30 len 42 contents:
read1msg: ld 0x7f25df51e220 msgid 1 message type extended-result
ber_scanf fmt ({eAA) ber:
read1msg: ld 0x7f25df51e220 0 new referrals
read1msg:  mark request completed, ld 0x7f25df51e220 msgid 1
request done: ld 0x7f25df51e220 msgid 1
res_errno: 2, res_error: <unsupported extended operation>, res_matched: <>
ldap_free_request (origid 1, msgid 1)
ldap_parse_extended_result
ber_scanf fmt ({eAA) ber:
ldap_parse_result
ber_scanf fmt ({iAA) ber:
ber_scanf fmt (}) ber:
ldap_msgfree
ldap_err2string
ldap_start_tls: Protocol error (2)
       additional info: unsupported extended operation
ldap_free_connection 1 1
ldap_send_unbind
ber_flush2: 7 bytes to sd 3
ldap_free_connection: actually freed

所以那裡也沒有好的資訊。

在 /var/log/syslog 我得到:

Jun  6 08:55:42 master slapd[21383]: conn=1008 fd=23 ACCEPT from IP=83.209.243.253:56440 (IP=0.0.0.0:389)
Jun  6 08:55:42 master slapd[21383]: conn=1008 op=0 EXT oid=1.3.6.1.4.1.1466.20037
Jun  6 08:55:42 master slapd[21383]: conn=1008 op=0 do_extended: unsupported operation "1.3.6.1.4.1.1466.20037"
Jun  6 08:55:42 master slapd[21383]: conn=1008 op=0 RESULT tag=120 err=2 text=unsupported extended operation
Jun  6 08:55:42 master slapd[21383]: conn=1008 op=1 UNBIND
Jun  6 08:55:42 master slapd[21383]: conn=1008 fd=23 closed

如果我對主機進行埠掃描,我會得到以下資訊:

Starting Nmap 6.40 ( http://nmap.org ) at 2014-06-06 08:56 CEST
Nmap scan report for h83-209-243-253.static.se.alltele.net (83.209.243.253)
Host is up (0.0072s latency).
Not shown: 996 closed ports
PORT    STATE SERVICE
22/tcp  open  ssh
80/tcp  open  http
389/tcp open  ldap
636/tcp open  ldapssl

但是當我檢查證書時

root@master:~# openssl s_client -connect daladevelop.se:636 -showcerts -state
CONNECTED(00000003)
SSL_connect:before/connect initialization
SSL_connect:unknown state
140244859233952:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:s23_lib.c:177:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 0 bytes and written 317 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
---

我覺得我顯然在深水中,完全不知道從這裡去哪裡。任何關於做什麼或獲得更好的調試日誌記錄的提示。

編輯:這是我從 cn=config中刪除的配置,它沒有提到任何關於 TLS 的內容。

我已經插入了我的 certinfo.ldif:

root@master:~# cat certinfo.ldif 
dn: cn=config

add: olcTLSCACertificateFile
olcTLSCACertificateFile: /etc/ssl/certs/cacert.pem
-
add: olcTLSCertificateFile
olcTLSCertificateFile: /etc/ssl/certs/daladevelop_slapd_cert.pem
-
add: olcTLSCertificateKeyFile
olcTLSCertificateKeyFile: /etc/ssl/private/daladevelop_slapd_key.pem

當這樣做時,我只得到這個作為答案。

root@master:~# sudo ldapmodify -Y EXTERNAL -H ldapi:/// -f certinfo.ldif 
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "cn=config"

所以還是不明智。

我在Persuading openldap to work with SSL on Ubuntu with cn=config找到了解決方案

連結到: http://rogermoffatt.com/2011/08/24/ubuntu-openldap-with-ssltls/ 有完整的解決方案。

引用自:https://serverfault.com/questions/602258