Skip to content

Commit c707c76

Browse files
docs: document LDAP certificate configuration for SSL/TLS (#221)
Refs #149 Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
1 parent 21981b3 commit c707c76

1 file changed

Lines changed: 103 additions & 11 deletions

File tree

Settings-Auth-LDAP.md

Lines changed: 103 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -201,17 +201,109 @@ out in lower-case (`fullname`).
201201

202202
### Certificate verification
203203

204-
When using LDAPS, a key and certificate must be installed on the directory
205-
server. When the client attaches to the server, it must make a decision to
206-
trust or reject the certificate that the server provided. The client will
207-
attempt to find the issuer of the certificate in a local repository of trusted
208-
certificate signers. If you install onto the directory server a certificate
209-
signed by an internal authority or a self-signed certificate, you will need to
210-
add the certificate of the issuer to the local repository on the Cacti server.
211-
If you do not, the client will surely reject the certificate, causing
212-
authentication to fail. To install a trusted certificate into the local
213-
repository, consult the documentation for the Operating System platform upon
214-
which you installed Cacti.
204+
When using LDAPS or STARTTLS, the Cacti server (as an LDAP client) must trust
205+
the certificate presented by the directory server. PHP's LDAP functions use the
206+
system OpenLDAP library, which reads its certificate configuration from
207+
`/etc/ldap/ldap.conf` (Debian/Ubuntu) or `/etc/openldap/ldap.conf`
208+
(RHEL/Rocky/AlmaLinux).
209+
210+
#### Adding a CA certificate on Linux
211+
212+
If the directory server uses a certificate signed by an internal CA or a
213+
self-signed certificate, install the CA certificate on the Cacti server and
214+
configure the OpenLDAP client library to trust it.
215+
216+
**Debian/Ubuntu:**
217+
218+
```shell
219+
# Copy the CA certificate
220+
cp /path/to/internal-ca.crt /usr/local/share/ca-certificates/internal-ca.crt
221+
222+
# Update the system trust store
223+
update-ca-certificates
224+
225+
```
226+
227+
Add the following line to `/etc/ldap/ldap.conf` if not already present:
228+
229+
```console
230+
TLS_CACERT /etc/ssl/certs/ca-certificates.crt
231+
```
232+
233+
**RHEL/Rocky/AlmaLinux:**
234+
235+
```shell
236+
# Copy the CA certificate
237+
cp /path/to/internal-ca.crt /etc/pki/ca-trust/source/anchors/internal-ca.crt
238+
239+
# Update the system trust store
240+
update-ca-trust extract
241+
242+
```
243+
244+
Add the following line to `/etc/openldap/ldap.conf` if not already present:
245+
246+
```console
247+
TLS_CACERT /etc/pki/tls/cert.pem
248+
```
249+
250+
#### Controlling certificate verification strictness
251+
252+
By default, the OpenLDAP library requires a valid, trusted certificate
253+
(`TLS_REQCERT demand`). You can relax this for testing, but do not disable
254+
verification in production; it exposes the LDAP bind to interception.
255+
256+
```console
257+
# /etc/ldap/ldap.conf or /etc/openldap/ldap.conf
258+
259+
# Require a valid certificate (default, recommended for production)
260+
TLS_REQCERT demand
261+
262+
# Accept certificates signed by the configured CA even if the hostname
263+
# does not match (useful if the LDAP server has an internal hostname)
264+
TLS_REQCERT allow
265+
266+
# Disable certificate verification entirely — DO NOT use in production
267+
TLS_REQCERT never
268+
```
269+
270+
#### Verifying the configuration
271+
272+
Test the LDAP TLS connection from the Cacti server before enabling it in Cacti:
273+
274+
```shell
275+
# Test LDAPS (port 636)
276+
openssl s_client -connect ldap.example.com:636 -CAfile /path/to/ca.crt
277+
278+
# Test STARTTLS (port 389)
279+
openssl s_client -connect ldap.example.com:389 -starttls ldap -CAfile /path/to/ca.crt
280+
```
281+
282+
> **Note**: `openssl s_client` verifies the certificate chain but does not
283+
> check the server hostname. Use `ldapsearch` or a dedicated TLS testing tool
284+
> (e.g. `testssl.sh`) to confirm hostname validation.
285+
286+
```shell
287+
# Full LDAP query over TLS using ldapsearch (-W prompts for password)
288+
ldapsearch -H ldaps://ldap.example.com -b "dc=example,dc=com" \
289+
-D "cn=service,dc=example,dc=com" -W "(cn=testuser)"
290+
```
291+
292+
A successful `CONNECTED` and `Verify return code: 0 (ok)` in the `openssl`
293+
output confirms the Cacti server trusts the certificate.
294+
295+
#### Adding a CA certificate on Windows (IIS)
296+
297+
On Windows, PHP's LDAP extension uses the Windows Certificate Store. Import the
298+
CA certificate using the Microsoft Management Console:
299+
300+
1. Open `mmc.exe`, go to **File > Add/Remove Snap-in**, add
301+
**Certificates** for the **Computer account**.
302+
2. Expand **Trusted Root Certification Authorities > Certificates**.
303+
3. Right-click, select **All Tasks > Import**, and follow the wizard to import
304+
the CA certificate (`.crt` or `.cer` file).
305+
4. Restart the IIS service (`net stop w3svc && net start w3svc`) for the
306+
change to take effect.
215307

216308
### Search Result Reference (Referrals)
217309

0 commit comments

Comments
 (0)