据我所知,这是一个证书验证问题,但我不知道原因。
~ > ldapsearch -x -ZZ -LLL -H ldap://ldap.dark.kow.is -b dc=dark,dc=kow,dc=is
ldap_start_tls: Connect error (-11)
但是,当我在同一台主机上使用 gnutls-cli 进行连接时,一切都完全正常。我真的不知道为什么会发生这种情况。CA 证书在系统存储中可用,用它签名的其他证书也很好。证书/CA 没有过期。主机名在 DNS 中匹配,因此没有超出有效性。
Ubuntu 18.04。
gnutls-cli --starttls-proto=ldap --print-cert -p 389 ldap.dark.kow.is
Processed 134 CA certificate(s).
Resolving 'ldap.dark.kow.is:389'...
Connecting to '10.10.220.213:389'...
- Certificate type: X.509
- Got a certificate list of 2 certificates.
- Certificate[0] info:
- subject `CN=ldap.dark.kow.is', issuer `CN=dark.kow.is CA', serial 0x637523035782280200a2dd2e262980d1, RSA key 4096 bits, signed using RSA-SHA256, activated `2018-01-13 20:22:12 UTC', expires `2028-01-11 20:22:12 UTC', pin-sha256="Xywzn8R32GsgoWQol5pKSJYrFVOrpXk1stF4kKPl1yY="
Public Key ID:
sha1:d7aa0336e36c3e63c8c0acb4d80dfa0541cadc0a
sha256:5f2c339fc477d86b20a16428979a4a48962b1553aba57935b2d17890a3e5d726
Public Key PIN:
pin-sha256:Xywzn8R32GsgoWQol5pKSJYrFVOrpXk1stF4kKPl1yY=
Public key's random art:
+--[ RSA 4096]----+
| . |
|oo. |
|Eo.. |
|. .. . |
| +. S . . |
| .=. = . . |
|o+.=.= + . |
|+...+ B .. |
| .. +.o.. |
+-----------------+
-----BEGIN CERTIFICATE-----
OMITTED
-----END CERTIFICATE-----
- Certificate[1] info:
- subject `CN=dark.kow.is CA', issuer `CN=dark.kow.is CA', serial 0x00d0d752ba5297a770, RSA key 2048 bits, signed using RSA-SHA256, activated `2016-12-24 17:49:30 UTC', expires `2026-12-22 17:49:30 UTC', pin-sha256="0Gze+gcPQQ0Dq4mT5pdt5H7z6HMM/NOeHc8pZ5z/BHg="
-----BEGIN CERTIFICATE-----
OMITTED
-----END CERTIFICATE-----
- Status: The certificate is trusted.
- Description: (TLS1.2)-(ECDHE-RSA-SECP256R1)-(AES-256-GCM)
- Session ID: BA:E5:46:52:6E:76:82:94:E7:AE:F2:5C:B5:74:95:54:7E:62:54:86:9F:23:D4:C3:D3:AF:C4:76:10:63:84:7A
- Ephemeral EC Diffie-Hellman parameters
- Using curve: SECP256R1
- Curve size: 256 bits
- Version: TLS1.2
- Key Exchange: ECDHE-RSA
- Server Signature: RSA-SHA256
- Cipher: AES-256-GCM
- MAC: AEAD
- Compression: NULL
- Options: extended master secret, safe renegotiation,
- Handshake was completed
- Simple Client Mode:
答案1
好吧,我终于明白了。解决方案在于我的/etc/ldap.conf
# Ubuntu has stuff built against GNUtls instead of openssl
# Get this from the gnutls-cli manpage under --priority
TLS_CIPHER_SUITE SECURE256
--priority SECURE256
我在发出命令时没有指定gnutls-cli
,因此它使用了不同的算法。包括以下内容:
~ > gnutls-cli --starttls-proto=ldap --priority SECURE256 -p 389 ldap.dark.kow.is
Processed 134 CA certificate(s).
Resolving 'ldap.dark.kow.is:389'...
Connecting to '10.10.220.213:389'...
- Certificate type: X.509
- Got a certificate list of 2 certificates.
- Certificate[0] info:
- subject `CN=ldap.dark.kow.is', issuer `CN=dark.kow.is CA', serial 0x637523035782280200a2dd2e262980d1, RSA key 4096 bits, signed using RSA-SHA256, activated `2018-01-13 20:22:12 UTC', expires `2028-01-11 20:22:12 UTC', pin-sha256="Xywzn8R32GsgoWQol5pKSJYrFVOrpXk1stF4kKPl1yY="
Public Key ID:
sha1:d7aa0336e36c3e63c8c0acb4d80dfa0541cadc0a
sha256:5f2c339fc477d86b20a16428979a4a48962b1553aba57935b2d17890a3e5d726
Public Key PIN:
pin-sha256:Xywzn8R32GsgoWQol5pKSJYrFVOrpXk1stF4kKPl1yY=
Public key's random art:
+--[ RSA 4096]----+
| . |
|oo. |
|Eo.. |
|. .. . |
| +. S . . |
| .=. = . . |
|o+.=.= + . |
|+...+ B .. |
| .. +.o.. |
+-----------------+
- Certificate[1] info:
- subject `CN=dark.kow.is CA', issuer `CN=dark.kow.is CA', serial 0x00d0d752ba5297a770, RSA key 2048 bits, signed using RSA-SHA256, activated `2016-12-24 17:49:30 UTC', expires `2026-12-22 17:49:30 UTC', pin-sha256="0Gze+gcPQQ0Dq4mT5pdt5H7z6HMM/NOeHc8pZ5z/BHg="
- Status: The certificate is NOT trusted. The certificate chain uses insecure algorithm.
*** PKI verification of server certificate failed...
*** Fatal error: Error in the certificate.
*** handshake has failed: Error in the certificate.
现在我遇到了与 LDAP 命令相同的故障,我必须在 ldap.conf 中禁用该级别的安全性才能使其重新工作。使用属于 SECURE256 类别的算法更改我的证书也可以。