SimpleACME
Sign inCreate account →
Software certificate guides

OpenLDAP TLS: configure LDAPS, StartTLS and certificate renewal

Deploy OpenLDAP 2.6 TLS through cn=config, distinguish LDAPS from required StartTLS, and validate binds, trust stores and certificate activation.

OpenLDAP can protect the same directory through StartTLS on the ordinary LDAP port or through an immediate TLS handshake on the LDAPS port. Applications often label these options ambiguously as SSL, TLS, or secure LDAP. Choosing the wrong mode can produce a failed bind even when the server's certificate is valid. Establish the protocol behavior first, then configure certificate files and authentication policy.

This guide targets OpenLDAP 2.6 with the dynamic cn=config configuration backend on Linux. The examples use a Debian-family package whose service account is openldap and whose listener startup configuration is in /etc/default/slapd. Other distributions use different service users and startup files. Keep your actual suffix, access controls, replication settings, and authentication databases intact; TLS deployment does not require rebuilding the directory.

Step 1: Choose StartTLS or LDAPS for each directory consumer

Inventory directory clients individually: operating-system login services, mail servers, application authentication libraries, administration tools, and replication consumers. Record whether each expects StartTLS on port 389 or an immediate TLS session on port 636. A client configured for LDAPS cannot simply connect to a StartTLS port and expect the server to infer its intention.

StartTLS begins as LDAP and upgrades the connection before sensitive operations. LDAPS starts TLS as soon as TCP connects. Both can authenticate the same server name when configured properly. The important difference for operations is whether clients require the upgrade to succeed. An optional StartTLS preference that falls back to an unencrypted bind is not the policy you want for directory passwords.

Reserve a working local ldapi:/// administration route before changing network listeners. On the example platform, root can use SASL EXTERNAL over that Unix socket to modify cn=config. Verify your distribution's access controls permit it. This route is valuable for recovery because an expired network certificate should not force you to disable verification merely to repair the server.

sudo ldapwhoami -Y EXTERNAL -H ldapi:///
sudo ldapsearch -Y EXTERNAL -H ldapi:/// -b cn=config -s base \
  olcTLSCertificateFile olcTLSCertificateKeyFile olcTLSCACertificateFile

Step 2: Issue a certificate for the LDAP service name

Use a stable name such as ldap.example.com in the certificate and in client connection settings. If a pool or failover list contains several server names, those names need an appropriate certificate strategy too. A generic certificate for a machine's management interface does not automatically authenticate its directory alias.

With an existing SimpleACME registration, add the assigned CNAME at your usual DNS host and configure the issuing ACME client through the Certbot integration or subscriber guides. Paid access permits the authenticated TXT challenge updates. The certificate and private key are created and retained by the ACME client; OpenLDAP receives ordinary PEM files during deployment.

This is particularly useful for LDAP services that should remain private. Directory ports need not become publicly accessible for an HTTP challenge, and the LDAP server does not need a broad DNS-provider API token. DNS validation still requires a publicly resolvable challenge delegation. A private directory address and a public validation hostname can coexist when your internal DNS resolves the service name appropriately.

Review the full chain against the actual clients. Java applications may use a JVM-specific trust store, while system tools use an operating-system CA bundle. A successful test with one does not validate the other. If your organization instead uses a private CA for directory services, distribute that CA deliberately and adapt this deployment workflow; do not mix trust models accidentally during an ACME migration.

Step 3: Install readable files and update cn=config through LDAP

Back up the current certificate pair and configuration before editing it. An export of cn=config contains sensitive material, potentially including password hashes and replication credentials, so protect it like a server secret. Use your existing consistent backup procedure for directory data; an ad hoc copy of live database files is not a substitute.

Copy the server chain and key into an application-specific directory, for example /etc/ldap/tls. The service must traverse the directory and read the key after dropping privileges. Root ownership with group openldap, directory mode 0750, chain mode 0644, and key mode 0640 is a common starting point on the example platform. Mandatory access policy may need to permit the location as well.

Do not edit generated files inside slapd.d by hand. Apply TLS attributes with ldapmodify against the local configuration backend. The following LDIF changes only the server certificate and key paths. Client-certificate CA configuration is separate and should not be added indiscriminately from the server's public chain.

dn: cn=config
changetype: modify
replace: olcTLSCertificateFile
olcTLSCertificateFile: /etc/ldap/tls/fullchain.pem
-
replace: olcTLSCertificateKeyFile
olcTLSCertificateKeyFile: /etc/ldap/tls/privkey.pem
sudo ldapmodify -Y EXTERNAL -H ldapi:/// -f /root/ldap-server-tls.ldif

Inspect the response and server logs. If the server rejects the change, investigate key readability, key matching, and certificate parsing before adding unrelated TLS attributes. OpenLDAP can be built against different TLS libraries, so a cipher string copied from an OpenSSL-specific example may be wrong for your package. Prefer a limited, verified change over a large collection of unexplained TLS knobs.

Step 4: Enable the intended listeners without weakening binds

For the example Debian-family package, the startup listener variable can include local administration plus LDAP and LDAPS. Changing that startup list requires the distribution's service restart procedure. It is not achieved solely by setting olcTLSCertificateFile in the directory's dynamic configuration.

# /etc/default/slapd on the example distribution
SLAPD_SERVICES="ldap:/// ldapi:/// ldaps:///"

Preserve the local socket and apply network restrictions suitable for directory access. If only StartTLS is needed, you do not need to expose LDAPS too. Conversely, applications that support only LDAPS need a real port 636 listener. Avoid enabling both merely to hide uncertainty about how your clients are configured.

Do not add a global authentication-strength rule without understanding its scope. OpenLDAP security-strength factors and access controls can enforce protected simple binds, but they can also affect replication and local maintenance workflows. Stage such policy changes with a list of affected consumers and a tested recovery path. First establish verified encrypted connections; then enforce the server-side bind policy deliberately using the appropriate database and global settings.

Client-side enforcement is essential during the transition. In OpenLDAP command-line clients, -ZZ requires StartTLS to succeed, whereas a weaker optional upgrade can conceal the problem you are trying to detect. Set trust verification to demand a valid server certificate rather than accepting every certificate because the directory is on a private network.

Step 5: Test transport, identity, and a limited directory operation

Use the appropriate OpenSSL mode to distinguish StartTLS from LDAPS. Both examples below verify the same expected DNS name and use the local system's public CA bundle. Replace the bundle path for your platform and add a private CA only when that is your deliberate trust model.

openssl s_client -starttls ldap -connect ldap.example.com:389 \
  -servername ldap.example.com -verify_hostname ldap.example.com \
  -verify_return_error -CAfile /etc/ssl/certs/ca-certificates.crt </dev/null

openssl s_client -connect ldap.example.com:636 \
  -servername ldap.example.com -verify_hostname ldap.example.com \
  -verify_return_error -CAfile /etc/ssl/certs/ca-certificates.crt </dev/null

Next test LDAP behavior with a low-privilege service account or an allowed anonymous root-DSE query. Do not use the directory's unrestricted administrator for every connection test. Enter bind passwords through the interactive prompt rather than placing them in command-line arguments or a published example.

LDAPTLS_CACERT=/etc/ssl/certs/ca-certificates.crt \
LDAPTLS_REQCERT=demand \
ldapsearch -H ldap://ldap.example.com -ZZ -x \
  -b '' -s base namingContexts supportedLDAPVersion

An installation that intentionally denies anonymous queries may return an authorization error even though TLS succeeded. Separate those layers in your diagnosis. Then test the actual application's bind and a harmless permitted search using its real runtime trust store. Finally, verify that a plaintext simple bind is refused wherever your reviewed server policy requires protection.

Account for directory connection pools during acceptance testing. An application server can hold an LDAP connection for hours, so a successful login may reuse a session established before the certificate change. Recycle one controlled application instance or use its documented pool-reset mechanism, then confirm that a new bind and search succeed. Avoid restarting every application simultaneously because a surge of fresh binds can create load unrelated to the certificate itself. Record which consumer versions and trust stores were checked so the next operator can identify the untested remainder.

Step 6: Plan certificate renewal around directory availability

Changing dynamic configuration and replacing files on disk are different events. Do not assume that overwriting a PEM file causes every OpenLDAP build to refresh its TLS context immediately. Use a deployment procedure validated for your installed version and TLS backend. A controlled service restart is a conservative activation method when context reload behavior has not been established.

In a replicated directory, rotate one node at a time and verify replication as well as client access. A replication consumer has its own server-verification settings and may connect using a different hostname. Check that applications can fail over before taking any node out of service. A redundant directory offers little protection if all clients hard-code the one node being restarted.

Stage and validate the new certificate pair, keep the preceding matched pair, and trigger activation only after a successful ACME renewal. Afterward, make a new verified network connection and inspect the served certificate. Rollback restores both previous files and, when changed, their original cn=config attributes through the retained local administration route. Monitor service expiry separately from SimpleACME's TXT-update history because a challenge change is not proof of successful issuance, activation, or directory authentication.

Frequently asked questions

Is StartTLS less encrypted than LDAPS?

Both can provide verified TLS protection. The critical distinction is that StartTLS clients must require a successful upgrade before sending credentials, while LDAPS expects TLS immediately on connection.

Can I edit TLS settings directly inside slapd.d?

Use the supported LDAP configuration interface instead. Hand-editing generated configuration files can bypass validation and create inconsistencies that are difficult to recover from later.

Why does ldapsearch work while my Java application fails?

They may use different CA stores, service names, and TLS defaults. Test the application's actual runtime and trust configuration rather than treating the system command-line tool as a complete compatibility test.

Does SimpleACME authenticate LDAP users?

No. It assists DNS validation for certificate issuance. LDAP bind authentication, authorization, replication, and private-key deployment remain responsibilities of your directory environment.

Sources

OpenLDAP 2.6 TLS guide describes the server and client TLS model. OpenLDAP dynamic configuration guide explains managing cn=config through LDAP operations rather than direct file edits.

KEEP EXPLORING

A little more clarity.

ONE CNAME. A REPEATABLE WORKFLOW.

Your next certificate. A little less complicated.

Keep your DNS provider and your ACME client.
Prepare your domain before activating paid updates.

Create your account →Explore the integrations