Configure OpenLDAP TLS and LDAPS on AlmaLinux 10 (StartTLS, Private CA, cn=config)

OpenLDAP on AlmaLinux series, part 3. Part 1 installed slapd and configured cn=config, and part 2 added users, groups and a read-only sssd-bind account. This part encrypts the connections with StartTLS and LDAPS. Part 4 covers replication with syncrepl, part 5 joins Linux clients with SSSD and part 6 adds password policies.

Right now every bind to ldap1.example.lan sends the DN and password across the network in clear text on port 389. Anyone who can capture traffic between a client and the server can read the cn=admin password, the sssd-bind password and every user password typed at a login prompt. SSSD in part 5 will not even authenticate users over an unencrypted connection. Before any client points at the directory, the server needs a certificate and TLS.

In this guide you create a small private CA, issue a server certificate with the right Subject Alternative Names, install it with permissions the ldap user can read and SELinux allows, load it into cn=config with ldapmodify, open port 636 in firewalld, configure clients in /etc/openldap/ldap.conf, and verify StartTLS and LDAPS with openssl s_client, ldapsearch and ldapwhoami. An optional step makes slapd refuse unencrypted connections, with a warning about the setting that locks you out of cn=config.

The LDIF, client commands and error messages below were run against the same EL10 build as parts 1 and 2: slapd 2.6.13 from EPEL 10 with the AlmaLinux 10 openldap-clients 2.6.13 tools and OpenSSL 3.5. The listener and permission checks come from the slapd.service unit and /usr/libexec/openldap/check-config.sh shipped in the EPEL package. Option meanings were checked against slapd-config(5), ldap.conf(5) and the TLS chapter of the OpenLDAP 2.6 Administrator’s Guide.

Applies to: AlmaLinux 10.x with openldap-servers 2.6 from EPEL 10, set up as in parts 1 and 2. The certificate steps, the cn=config LDIF and the client settings are the same on RHEL 10, Rocky Linux 10, Oracle Linux 10 and any OpenLDAP 2.5/2.6 server built with OpenSSL.

Lab layout

HostIPRole
ldap1.example.lan192.168.1.70OpenLDAP provider from parts 1 and 2; gets the server certificate
client1.example.lan192.168.1.71Test client with openldap-clients; trusts the CA
ldap2.example.lan192.168.1.72Reserved for replication in part 4 (gets its own certificate the same way)
SettingValue used here
Base DN (suffix)dc=example,dc=lan
Root DNcn=admin,dc=example,dc=lan
CA working directory/root/ldap-ca on ldap1 (any admin host works)
Server certificate files/etc/openldap/certs/ca.crt, ldap1.crt, ldap1.key
Certificate names (SAN)DNS:ldap1.example.lan, DNS:ldap1, IP:192.168.1.70
Ports389/tcp (LDAP + StartTLS), 636/tcp (LDAPS)

StartTLS or LDAPS?

OpenLDAP offers two ways to encrypt the same LDAP protocol, and the server you build here supports both with one certificate:

StartTLSLDAPS
Port389 (same as plain LDAP)636
How it worksClient connects in clear, sends the StartTLS extended operation (OID 1.3.6.1.4.1.1466.20037), then both sides switch to TLS before the bindTLS handshake first, LDAP inside it (like HTTPS)
URIldap://ldap1.example.lan plus -ZZ or ldap_id_use_start_tls = trueldaps://ldap1.example.lan
StandardRFC 4511/4513, the official LDAPv3 wayNever standardized for LDAPv3, but universally supported
FirewallNothing newOpen 636/tcp
Failure mode to watchA client that tries StartTLS but carries on in clear if it fails (-Z instead of -ZZ)None; no TLS means no connection

Use whichever your clients handle best. SSSD, sudo-ldap, Linux PAM tools and most applications do both. Appliances and Windows software often only offer "LDAPS on 636". Enabling both costs nothing, and the optional step 9 makes sure nobody quietly falls back to clear text on 389.

Prerequisites

  • The server from part 1 with the entries from part 2, and root (or sudo) on ldap1.
  • Working name resolution. Clients check that the name in the URI matches a name in the certificate, so ldap1.example.lan must resolve to 192.168.1.70 on every client (DNS or /etc/hosts). getent hosts ldap1.example.lan should print the address.
  • Correct time on server and clients (chronyc tracking). A client whose clock is behind the certificate’s notBefore rejects it as "not yet valid".
  • openssl on the host that runs the CA (installed by default on AlmaLinux 10; otherwise dnf install openssl).

Look at the current state first. The EPEL unit already starts slapd with an ldaps:/// listener, but without a certificate it cannot complete a handshake:

ss -ltnp | grep slapd
LISTEN 0      2048         0.0.0.0:389        0.0.0.0:*    users:(("slapd",pid=1312,fd=7))
LISTEN 0      2048         0.0.0.0:636        0.0.0.0:*    users:(("slapd",pid=1312,fd=8))
LISTEN 0      2048            [::]:389           [::]:*    users:(("slapd",pid=1312,fd=9))
LISTEN 0      2048            [::]:636           [::]:*    users:(("slapd",pid=1312,fd=10))
ldapwhoami -x -H ldaps://ldap1.example.lan -D cn=admin,dc=example,dc=lan -W
ldapwhoami -x -ZZ -H ldap://ldap1.example.lan -D cn=admin,dc=example,dc=lan -W
ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
ldap_start_tls: Protocol error (2)
	additional info: unsupported extended operation

Those are the two messages you get from a slapd with no TLS configuration: LDAPS fails at the connection, and StartTLS is refused because the server does not advertise the extended operation yet. The slapd log shows TLS: init_def_ctx: . and closed (TLS negotiation failure) for the LDAPS attempt.

Step 1: Create a private CA

If you already have an internal CA (Active Directory Certificate Services, FreeIPA, HashiCorp Vault, a corporate PKI team) or a public certificate for the name, skip to the box at the end of step 2: you only need the PEM certificate, the unencrypted private key and the CA chain. Otherwise, a two-file CA is enough for a lab or a small site. This is the same workflow used in MariaDB TLS and troubleshooting on AlmaLinux; the older certificate authority on CentOS 6 post shows the full openssl ca directory layout if you want a CA database with an index and CRLs.

Keep the CA key off the LDAP server if you can. For the lab, a root-only directory on ldap1 is fine:

mkdir -p /root/ldap-ca && cd /root/ldap-ca
umask 077

openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:4096 -out ca.key

openssl req -x509 -new -key ca.key -sha256 -days 3650 \
  -subj "/O=Example LAN/CN=Example LAN Root CA" \
  -addext "basicConstraints=critical,CA:TRUE" \
  -addext "keyUsage=critical,keyCertSign,cRLSign" \
  -out ca.crt

ca.crt is the file every client and server will trust. ca.key signs certificates; anyone who has it can impersonate any server in your network, so back it up somewhere safe and offline. Add -aes256 to the genpkey command if you want it passphrase-protected (you then type the passphrase each time you sign).

Step 2: Issue the server certificate with Subject Alternative Names

Modern TLS clients, including libldap in OpenLDAP 2.5+, match the host name against the Subject Alternative Name (SAN) extension, not against the CN. Put every name clients will use in the SAN: the FQDN, the short name if anyone types it, and the IP address if any client connects by IP. Here a 3072-bit RSA key is used, which satisfies both the DEFAULT and FUTURE system crypto policies:

cd /root/ldap-ca

openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:3072 -out ldap1.key

openssl req -new -key ldap1.key \
  -subj "/O=Example LAN/CN=ldap1.example.lan" -out ldap1.csr

cat > ldap1.ext <<'EOF'
basicConstraints = critical, CA:FALSE
keyUsage = critical, digitalSignature, keyEncipherment
extendedKeyUsage = serverAuth
subjectAltName = DNS:ldap1.example.lan, DNS:ldap1, IP:192.168.1.70
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
EOF

openssl x509 -req -in ldap1.csr -CA ca.crt -CAkey ca.key -CAcreateserial \
  -days 397 -sha256 -extfile ldap1.ext -out ldap1.crt
Certificate request self-signature ok
subject=O=Example LAN, CN=ldap1.example.lan

The extensions file is applied by the CA at signing time, so the SAN does not have to be in the CSR. Check the result before you install it:

openssl x509 -in ldap1.crt -noout -subject -issuer -dates \
  -ext subjectAltName,keyUsage,extendedKeyUsage
openssl verify -CAfile ca.crt ldap1.crt
subject=O=Example LAN, CN=ldap1.example.lan
issuer=O=Example LAN, CN=Example LAN Root CA
notBefore=Nov 21 09:18:05 2026 GMT
notAfter=Dec 23 09:18:05 2027 GMT
X509v3 Key Usage: critical
    Digital Signature, Key Encipherment
X509v3 Extended Key Usage: 
    TLS Web Server Authentication
X509v3 Subject Alternative Name: 
    DNS:ldap1.example.lan, DNS:ldap1, IP Address:192.168.1.70
ldap1.crt: OK

And confirm the key belongs to the certificate (no output from cmp plus match means they pair):

cmp <(openssl x509 -in ldap1.crt -noout -pubkey) <(openssl pkey -in ldap1.key -pubout) && echo match

For ldap2 in part 4, repeat this step with ldap2 names and address. If you plan to put both servers behind one name (a DNS round robin such as ldap.example.lan), add that name to the SAN of both certificates.

Using an existing certificate instead: you need (1) the server certificate in PEM format with the server’s DNS name in the SAN and serverAuth in the extended key usage, (2) the matching private key in PEM without a passphrase (slapd cannot prompt for one; remove it with openssl pkey -in enc.key -out ldap1.key), and (3) the issuing CA chain. If there is an intermediate CA, put the intermediate(s) and the root together in the CA file (cat intermediate.crt root.crt > ca.crt) or append the intermediate to the server certificate file. A Windows .pfx converts with openssl pkcs12 -in ldap1.pfx -nokeys -clcerts -out ldap1.crt and openssl pkcs12 -in ldap1.pfx -nocerts -noenc -out ldap1.key.

Step 3: Install the files with the right owner, mode and SELinux label

slapd starts as root, reads its configuration and then drops to the ldap user (UID/GID 55, from -u ldap in the unit). TLS is initialised after the privilege drop, so the ldap user must be able to read the private key. The EPEL package does not create /etc/openldap/certs, but the SELinux policy already labels that path slapd_cert_t, so it is the natural home:

mkdir -p /etc/openldap/certs
cp /root/ldap-ca/ca.crt /root/ldap-ca/ldap1.crt /root/ldap-ca/ldap1.key /etc/openldap/certs/

chown root:ldap /etc/openldap/certs/ldap1.key
chmod 0640 /etc/openldap/certs/ldap1.key
chmod 0644 /etc/openldap/certs/ca.crt /etc/openldap/certs/ldap1.crt
restorecon -Rv /etc/openldap/certs

ls -lZ /etc/openldap/certs
-rw-r--r--. 1 root root unconfined_u:object_r:slapd_cert_t:s0 1915 Nov 21 03:30 ca.crt
-rw-r--r--. 1 root root unconfined_u:object_r:slapd_cert_t:s0 1826 Nov 21 03:30 ldap1.crt
-rw-r-----. 1 root ldap unconfined_u:object_r:slapd_cert_t:s0 2484 Nov 21 03:30 ldap1.key

Root owns the key and the ldap group can only read it: slapd can use it, but a compromised slapd cannot rewrite it, and nobody else can read it. Use cp, not mv: mv keeps the admin_home_t label the files had in /root, and SELinux then blocks slapd even though the Unix permissions look right. restorecon fixes either case.

Test the read as the service user, exactly what the unit’s check-config.sh pre-start check does:

runuser -u ldap -- test -r /etc/openldap/certs/ldap1.key && echo readable
readable

Step 4: Point slapd at the certificate in cn=config

The TLS settings live in the global cn=config entry. Set the CA, certificate and key in one modify operation: slapd builds a new TLS context from the three files when the change is applied, and if anything is wrong (missing file, unreadable key, key that does not match the certificate) the whole modify is rejected and the running configuration is left untouched. olcTLSProtocolMin: 3.3 means TLS 1.2 or newer (the value is 3.(x+1) for TLS 1.x):

cat > /root/ldap/50-tls.ldif <<'EOF'
dn: cn=config
changetype: modify
replace: olcTLSCACertificateFile
olcTLSCACertificateFile: /etc/openldap/certs/ca.crt
-
replace: olcTLSCertificateFile
olcTLSCertificateFile: /etc/openldap/certs/ldap1.crt
-
replace: olcTLSCertificateKeyFile
olcTLSCertificateKeyFile: /etc/openldap/certs/ldap1.key
-
replace: olcTLSProtocolMin
olcTLSProtocolMin: 3.3
EOF

ldapmodify -Y EXTERNAL -H ldapi:/// -f /root/ldap/50-tls.ldif
SASL/EXTERNAL authentication started
SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
SASL SSF: 0
modifying entry "cn=config"

replace works whether or not the attribute already exists, so the same file is safe to run again (you will use that for renewals). Confirm:

ldapsearch -Q -LLL -Y EXTERNAL -H ldapi:/// -b cn=config -s base \
  olcTLSCACertificateFile olcTLSCertificateFile olcTLSCertificateKeyFile olcTLSProtocolMin
dn: cn=config
olcTLSCACertificateFile: /etc/openldap/certs/ca.crt
olcTLSCertificateFile: /etc/openldap/certs/ldap1.crt
olcTLSCertificateKeyFile: /etc/openldap/certs/ldap1.key
olcTLSProtocolMin: 3.3

If the modify fails with ldap_modify: Other (e.g., implementation specific) error (80), the client gives no reason. The reason is in the slapd log (journalctl -u slapd -n 20):

slapd log lineMeaning
TLS: could not use key file `/etc/openldap/certs/ldap1.key'. followed by system library::No such file or directoryWrong path or file not copied
same first line, then system library::Permission deniedThe ldap user cannot read the key (owner/mode), or SELinux denied it (label)
same first line, then x509 certificate routines::key values mismatchThe key is not the one the certificate was issued for

olcTLSVerifyClient stays at its default never: the server does not ask clients for certificates. Client-certificate authentication (SASL EXTERNAL over TLS) is a separate topic. Also leave olcTLSCipherSuite unset so slapd follows the system crypto policy (see troubleshooting).

Step 5: Check the listeners (ldaps:///) and restart

On RHEL 7 and CentOS 7 you enabled LDAPS by adding ldaps:/// to SLAPD_URLS in /etc/sysconfig/slapd. The EL10 package from EPEL works differently: there is no /etc/sysconfig/slapd and the unit does not read SLAPD_URLS. The listeners are hard-coded in ExecStart, and ldaps:/// is already among them:

systemctl cat slapd | grep -E 'ExecStart' 
ExecStartPre=/usr/libexec/openldap/check-config.sh
ExecStart=/usr/sbin/slapd -u ldap -h "ldap:/// ldaps:/// ldapi:///"

So for the default setup there is nothing to change. If you want different listeners, for example only on the LAN address and not on every interface, override ExecStart with a drop-in instead of editing the packaged unit (the empty ExecStart= line clears the original):

systemctl edit slapd
[Service]
ExecStart=
ExecStart=/usr/sbin/slapd -u ldap -h "ldap://192.168.1.70/ ldaps://192.168.1.70/ ldapi:///"

Keep ldapi:/// in the list, or you lose the root EXTERNAL access to cn=config used throughout this series. Creating /etc/sysconfig/slapd with SLAPD_URLS= on EL10 does nothing: check-config.sh only reads SLAPD_OPTIONS from that file for its own checks.

The ldapmodify in step 4 activated TLS immediately, but restart once now to prove slapd starts cleanly with the certificate (the pre-start script checks that the ldap user can read every olcTLS* file):

systemctl restart slapd
systemctl status slapd --no-pager -l | head -5
● slapd.service - OpenLDAP Server Daemon
     Loaded: loaded (/usr/lib/systemd/system/slapd.service; enabled; preset: disabled)
     Active: active (running) since Sat 2026-11-21 03:32:10 CST; 3s ago

Step 6: Open LDAPS in firewalld

Part 1 opened only the ldap service (389). StartTLS needs nothing more; LDAPS needs 636/tcp, which firewalld ships as the ldaps service. Open it to everyone in the zone, or only to the client subnet with a rich rule (see the firewalld cheat sheet for zones and rich rules):

firewall-cmd --info-service=ldaps | grep ports
firewall-cmd --permanent --add-service=ldaps
# or, restricted to the LAN:
# firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.0/24" service name="ldaps" accept'
firewall-cmd --reload
firewall-cmd --list-services
  ports: 636/tcp
cockpit dhcpv6-client ldap ldaps ssh

SELinux needs no port change: 636 is already ldap_port_t (semanage port -l | grep ldap_port_t).

Step 7: Test the handshake with openssl s_client

Before involving any LDAP client, check what the server actually presents. Run this on ldap1 or client1 with a copy of ca.crt:

openssl s_client -connect ldap1.example.lan:636 -CAfile /etc/openldap/certs/ca.crt \
  -verify_hostname ldap1.example.lan -showcerts </dev/null 2>/dev/null \
  | grep -E '^ *[0-9] s:|^ *i:|Protocol|Cipher is|Verif' 
Certificate chain
 0 s:O=Example LAN, CN=ldap1.example.lan
   i:O=Example LAN, CN=Example LAN Root CA
 1 s:O=Example LAN, CN=Example LAN Root CA
   i:O=Example LAN, CN=Example LAN Root CA
Verification: OK
New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Protocol: TLSv1.3
Verify return code: 0 (ok)

Verify return code: 0 (ok) plus -verify_hostname is the same test an LDAP client performs: trusted chain and matching name. slapd sends the root along with the server certificate because the CA file is configured. StartTLS on port 389 can be tested the same way; OpenSSL speaks the LDAP StartTLS request itself:

openssl s_client -connect ldap1.example.lan:389 -starttls ldap \
  -CAfile /etc/openldap/certs/ca.crt -verify_hostname ldap1.example.lan </dev/null 2>/dev/null \
  | grep -E 'Protocol|Verify return' 
Protocol: TLSv1.3
Verify return code: 0 (ok)

To check what is live on a server (for example after a renewal), pipe the presented certificate into openssl x509:

openssl s_client -connect ldap1.example.lan:636 </dev/null 2>/dev/null \
  | openssl x509 -noout -subject -enddate -ext subjectAltName
subject=O=Example LAN, CN=ldap1.example.lan
notAfter=Dec 23 09:19:19 2027 GMT
X509v3 Subject Alternative Name: 
    DNS:ldap1.example.lan, DNS:ldap1, IP Address:192.168.1.70

Step 8: Make clients trust the CA (/etc/openldap/ldap.conf)

The OpenLDAP client tools and library read /etc/openldap/ldap.conf. By default they demand a valid certificate (TLS_REQCERT demand), so a client that does not trust your CA refuses to connect:

ldapwhoami -x -H ldaps://ldap1.example.lan -D cn=admin,dc=example,dc=lan -W
ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
	additional info: error:0A000086:SSL routines::certificate verify failed (self-signed certificate in certificate chain)

Give the client the CA certificate. Copy ca.crt to client1 (and to ldap1 itself, so the tools on the server also work), then choose one of two ways to trust it.

Option A: TLS_CACERT in ldap.conf (OpenLDAP tools only)

scp root@ldap1.example.lan:/etc/openldap/certs/ca.crt /tmp/
mkdir -p /etc/openldap/certs
install -m 0644 /tmp/ca.crt /etc/openldap/certs/ca.crt
restorecon -Rv /etc/openldap/certs

Edit /etc/openldap/ldap.conf on client1. Keep the existing SASL_NOCANON on line and the BASE/URI lines from part 1, switch the URI to LDAPS and add the two TLS lines:

BASE        dc=example,dc=lan
URI         ldaps://ldap1.example.lan
TLS_CACERT  /etc/openldap/certs/ca.crt
TLS_REQCERT demand
SASL_NOCANON on

If you prefer to keep URI ldap://ldap1.example.lan (StartTLS), the TLS lines are the same; you then add -ZZ to each command. Individual users can override settings in ~/.ldaprc, and for a one-off test the environment works too: LDAPTLS_CACERT=/tmp/ca.crt ldapwhoami ....

Option B: the system trust store (all programs)

When TLS_CACERT is not set, OpenLDAP 2.6 on EL10 falls back to OpenSSL’s default trust store, which is the system bundle that update-ca-trust maintains. Adding the CA there makes it trusted by ldapsearch, curl, Python and SSSD at once:

cp /tmp/ca.crt /etc/pki/ca-trust/source/anchors/example-lan-root-ca.crt
update-ca-trust
trust list --filter=ca-anchors | grep -A2 'Example LAN' 

Either way, leave TLS_REQCERT at demand. allow and never make the error go away by not checking the certificate at all, which brings back exactly the man-in-the-middle risk TLS is meant to remove. They are acceptable only for a quick diagnosis (does the TLS layer work at all?), never in a config file.

Step 9: Verify with ldapwhoami and ldapsearch

From client1, test LDAPS on 636, StartTLS on 389 and a real search:

ldapwhoami -x -H ldaps://ldap1.example.lan -D cn=admin,dc=example,dc=lan -W
ldapwhoami -x -ZZ -H ldap://ldap1.example.lan -D cn=admin,dc=example,dc=lan -W
Enter LDAP Password:
dn:cn=admin,dc=example,dc=lan
Enter LDAP Password:
dn:cn=admin,dc=example,dc=lan
ldapsearch -x -ZZ -H ldap://ldap1.example.lan -D cn=admin,dc=example,dc=lan -W -LLL '(uid=jdoe)' dn uidNumber
Enter LDAP Password:
dn: uid=jdoe,ou=People,dc=example,dc=lan
uidNumber: 10001

Use -ZZ, not -Z. The single -Z only tries StartTLS, and ldapsearch(1) documents that the command carries on even if the StartTLS operation fails; -ZZ requires it to succeed. With the ldaps:// URI from option A in ldap.conf, plain ldapwhoami -x -D ... -W already uses TLS.

On ldap1 the stats log level set in part 1 records every TLS session, so you can prove the connection was encrypted:

journalctl -u slapd --since '-5 min' | grep -E 'STARTTLS|TLS established' 
slapd[1312]: conn=1021 fd=12 TLS established tls_ssf=256 ssf=256 tls_proto=TLSv1.3 tls_cipher=TLS_AES_256_GCM_SHA384
slapd[1312]: conn=1032 op=0 STARTTLS
slapd[1312]: conn=1032 fd=12 TLS established tls_ssf=256 ssf=256 tls_proto=TLSv1.3 tls_cipher=TLS_AES_256_GCM_SHA384

A connection by IP address works only because the IP is in the SAN. Connecting with a name that is not in the certificate fails with the hostname error, which is the check doing its job:

ldapwhoami -x -H ldaps://ldap.example.lan -D cn=admin,dc=example,dc=lan -W
ldap_sasl_bind(SIMPLE): Can't contact LDAP server (-1)
	additional info: TLS: hostname does not match name in peer certificate

Step 10 (optional): Refuse unencrypted connections with olcSecurity

Clients that forget -ZZ still bind in clear on 389. olcSecurity makes slapd require a minimum security strength factor (SSF) for every operation. TLS sessions get an SSF of 256 (the cipher key size), ldapi:// gets 71 (olcLocalSSF), and plain LDAP gets 0. The safe setting is ssf=1: it rejects only unencrypted network connections.

cat > /root/ldap/51-require-tls.ldif <<'EOF'
dn: cn=config
changetype: modify
replace: olcSecurity
olcSecurity: ssf=1
EOF

ldapmodify -Q -Y EXTERNAL -H ldapi:/// -f /root/ldap/51-require-tls.ldif

Now a plain bind is refused, while StartTLS, LDAPS and root access over ldapi keep working:

ldapwhoami -x -H ldap://ldap1.example.lan -D cn=admin,dc=example,dc=lan -W
ldap_bind: Confidentiality required (13)
	additional info: confidentiality required
ldapwhoami -x -ZZ -H ldap://ldap1.example.lan -D cn=admin,dc=example,dc=lan -W
ldapwhoami -Q -Y EXTERNAL -H ldapi:///
dn:cn=admin,dc=example,dc=lan
dn:gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth

Do not use olcSecurity: tls=1 or ssf=128 globally. Both look like the obvious choice, and both lock you out of cn=config. ldapi:// is not a TLS connection and its SSF is only 71, so with either value the root EXTERNAL bind is rejected with Confidentiality required (13) (TLS confidentiality required or stronger confidentiality required), and you can no longer run ldapmodify on cn=config to undo it. If it happens, fix it offline:

systemctl stop slapd
cat > /root/ldap/52-remove-security.ldif <<'EOF'
dn: cn=config
changetype: modify
delete: olcSecurity
EOF
runuser -u ldap -- slapmodify -F /etc/openldap/slapd.d -n 0 -l /root/ldap/52-remove-security.ldif
systemctl start slapd

slapmodify edits the stopped configuration database directly and keeps the files in slapd.d consistent (never edit them with a text editor). Running it as the ldap user keeps file ownership intact.

Renewing the certificate

The server certificate above is valid for 397 days. Put the expiry date in your calendar or monitoring (openssl x509 -enddate -noout -in /etc/openldap/certs/ldap1.crt). To renew, repeat step 2 (a new CSR with the existing key is fine), copy the new ldap1.crt over the old one with the same mode and label, and either restart slapd or re-run the step 4 LDIF. Re-applying 50-tls.ldif with unchanged paths makes slapd reload the files and serve the new certificate without dropping the service; the openssl s_client ... | openssl x509 -noout -serial output changes immediately. If the CA itself changes, distribute the new ca.crt to every client before switching the server.

Crypto policies

AlmaLinux 10 applies a system-wide crypto policy to OpenSSL, and slapd and libldap inherit it as long as you do not set olcTLSCipherSuite or TLS_CIPHER_SUITE. Check the active policy with:

update-crypto-policies --show
DEFAULT

Under DEFAULT, TLS 1.0 and 1.1 are disabled, RSA keys must be at least 2048 bits and SHA-1 signatures are not accepted. That is why olcTLSProtocolMin: 3.3 changes nothing on a default system; it documents the intent and protects you if the policy is ever relaxed. The FUTURE policy raises RSA to 3072 bits, which the key in step 2 already meets. When an old client, an appliance or an old certificate fails the handshake, fix the client or reissue the certificate (SHA-256, at least 2048-bit RSA) rather than switching the server to LEGACY.

Troubleshooting

Most TLS problems show up on the client as Can't contact LDAP server (-1), which also means "server down". Add -d 1 to the client command for the TLS trace (look for the TLS certificate verification: lines), and read journalctl -u slapd on the server. Messages marked with an asterisk are quoted from the packaged scripts or documentation; all others were reproduced on slapd 2.6.13.

Symptom or errorLikely causeFix
Can't contact LDAP server (-1), certificate verify failed (self-signed certificate in certificate chain)Client does not trust the CAStep 8: TLS_CACERT or the system trust store; check the path in ldap.conf is readable
TLS: hostname does not match name in peer certificate (on ldap_sasl_bind, or on ldap_start_tls: Connect error (-11))The name or IP in the URI is not in the SAN (short name, alias, IP, round-robin name)Use the FQDN in the URI, or reissue the certificate with the missing SAN entry
ldap_start_tls: Protocol error (2), unsupported extended operationslapd has no TLS configuration (step 4 not applied, or applied to a different server)Check ldapsearch -Y EXTERNAL -H ldapi:/// -b cn=config -s base olcTLSCertificateFile
ldap_modify: Other (e.g., implementation specific) error (80) when applying 50-tls.ldifslapd could not build the TLS contextRead the slapd log: No such file or directory, Permission denied or key values mismatch (table in step 4)
slapd fails to start; journal shows TLS certificate/key/DB '/etc/openldap/certs/ldap1.key' is not readable. *Key mode/owner changed (for example a renewal copied it as root:root 0600); check-config.sh stops the unitchown root:ldap, chmod 0640, then runuser -u ldap -- test -r ...
Permission denied although ls -l looks right *SELinux label: the file was moved from /root and is admin_home_tls -Z, restorecon -Rv /etc/openldap/certs; ausearch -m AVC -ts recent -c slapd shows the denial. For a custom directory, semanage fcontext -a -t slapd_cert_t "/srv/ldapcerts(/.*)?" then restorecon
Can't contact LDAP server (-1) on ldaps:// from client1 but s_client works on ldap1636/tcp blockedStep 6: firewall-cmd --list-services must show ldaps
ldap_start_tls: Can't contact LDAP server (-1)StartTLS (-ZZ) sent to port 636, or ldaps:// pointed at 389StartTLS uses ldap:// on 389; LDAPS uses ldaps:// on 636
Confidentiality required (13)olcSecurity is set and the client did not use TLSAdd -ZZ or use ldaps://; if ldapi is refused too, remove olcSecurity offline with slapmodify (step 10)
certificate has expired or certificate is not yet valid in the -d 1 trace *Expired certificate, or a client clock that is wrongopenssl x509 -enddate; renew; check chronyc tracking
Handshake fails only for an old client or appliance *Crypto policy: TLS 1.0/1.1, SHA-1 signature or a small RSA keyUpgrade the client or reissue the certificate; do not weaken the server policy
s_client: Verify return code: 62 (hostname mismatch)Same SAN problem, seen from OpenSSLCheck the names with openssl x509 -noout -ext subjectAltName
s_client: unexpected eof while reading right after CONNECTEDPort 636 open but slapd has no certificateStep 4

What is next

The directory now accepts only encrypted binds from properly configured clients, with a certificate that clients verify by name. Part 4 adds ldap2.example.lan as a replica with syncrepl, using a certificate issued from the same CA and starttls=critical in the replication agreement so the replicated data and the replication password also travel encrypted. Part 5 configures SSSD on client1 with the sssd-bind account from part 2, the CA from this part (ldap_tls_cacert or the system trust store) and min_id = 10000, so getent passwd jdoe and ssh jdoe@client1 work. Part 6 adds password policies with the ppolicy overlay.

Leave a Reply

Your email address will not be published. Required fields are marked *