fix: LDAP TLS handshake fails with StartTLS and tls_skip_verify=off (#21582)
Some checks failed
VulnCheck / Analysis (push) Has been cancelled

Fixes #21581
This commit is contained in:
mosesdd 2025-09-17 09:58:27 +02:00 committed by GitHub
parent ae71d76901
commit 7a80ec1cce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -21,6 +21,7 @@ import (
"crypto/tls"
"crypto/x509"
"errors"
"net"
"sort"
"time"
@ -190,10 +191,18 @@ func Lookup(s config.Config, rootCAs *x509.CertPool) (l Config, err error) {
if ldapServer == "" {
return l, nil
}
// Set ServerName in TLS config for proper certificate validation
host, _, err := net.SplitHostPort(ldapServer)
if err != nil {
host = ldapServer
}
l.LDAP = ldap.Config{
ServerAddr: ldapServer,
SRVRecordName: getCfgVal(SRVRecordName),
TLS: &tls.Config{
ServerName: host,
MinVersion: tls.VersionTLS12,
NextProtos: []string{"h2", "http/1.1"},
ClientSessionCache: tls.NewLRUClientSessionCache(100),