tls.sdf revision 1.1.1.7 1 1.1.1.5 tron # $OpenLDAP$
2 1.1.1.7 christos # Copyright 1999-2017 The OpenLDAP Foundation, All Rights Reserved.
3 1.1 lukem # COPYING RESTRICTIONS APPLY, see COPYRIGHT.
4 1.1 lukem
5 1.1 lukem H1: Using TLS
6 1.1 lukem
7 1.1 lukem OpenLDAP clients and servers are capable of using the
8 1.1 lukem {{TERM[expand]TLS}} ({{TERM:TLS}}) framework to provide
9 1.1 lukem integrity and confidentiality protections and to support
10 1.1 lukem LDAP authentication using the {{TERM:SASL}} {{TERM:EXTERNAL}} mechanism.
11 1.1 lukem TLS is defined in {{REF:RFC4346}}.
12 1.1 lukem
13 1.1 lukem Note: For generating certifcates, please reference {{URL:http://www.openldap.org/faq/data/cache/185.html}}
14 1.1 lukem
15 1.1 lukem H2: TLS Certificates
16 1.1 lukem
17 1.1 lukem TLS uses {{TERM:X.509}} certificates to carry client and server
18 1.1 lukem identities. All servers are required to have valid certificates,
19 1.1 lukem whereas client certificates are optional. Clients must have a
20 1.1 lukem valid certificate in order to authenticate via SASL EXTERNAL.
21 1.1 lukem For more information on creating and managing certificates,
22 1.1.1.5 tron see the {{PRD:OpenSSL}}, {{PRD:GnuTLS}}, or {{PRD:MozNSS}} documentation,
23 1.1.1.5 tron depending on which TLS implementation libraries you are using.
24 1.1 lukem
25 1.1 lukem H3: Server Certificates
26 1.1 lukem
27 1.1 lukem The {{TERM:DN}} of a server certificate must use the {{EX:CN}}
28 1.1 lukem attribute to name the server, and the {{EX:CN}} must carry the
29 1.1 lukem server's fully qualified domain name. Additional alias names and
30 1.1 lukem wildcards may be present in the {{EX:subjectAltName}} certificate
31 1.1 lukem extension. More details on server certificate names are in
32 1.1 lukem {{REF:RFC4513}}.
33 1.1 lukem
34 1.1 lukem H3: Client Certificates
35 1.1 lukem
36 1.1 lukem The DN of a client certificate can be used directly as an
37 1.1 lukem authentication DN.
38 1.1 lukem Since X.509 is a part of the {{TERM:X.500}} standard and LDAP
39 1.1 lukem is also based on X.500, both use the same DN formats and
40 1.1 lukem generally the DN in a user's X.509 certificate should be
41 1.1 lukem identical to the DN of their LDAP entry. However, sometimes
42 1.1 lukem the DNs may not be exactly the same, and so the mapping
43 1.1 lukem facility described in
44 1.1 lukem {{SECT:Mapping Authentication Identities}}
45 1.1 lukem can be applied to these DNs as well.
46 1.1 lukem
47 1.1 lukem H2: TLS Configuration
48 1.1 lukem
49 1.1 lukem After obtaining the required certificates, a number of options must
50 1.1 lukem be configured on both the client and the server to enable TLS and
51 1.1 lukem make use of the certificates. At a minimum, the clients must be
52 1.1 lukem configured with the name of the file containing all of the
53 1.1 lukem {{TERM[expand]CA}} (CA) certificates it will trust. The server must
54 1.1 lukem be configured with the {{TERM:CA}} certificates and also its own
55 1.1 lukem server certificate and private key.
56 1.1 lukem
57 1.1 lukem Typically a single CA will have issued the server certificate
58 1.1 lukem and all of the trusted client certificates, so the server only
59 1.1 lukem needs to trust that one signing CA. However, a client may wish
60 1.1 lukem to connect to a variety of secure servers managed by different
61 1.1 lukem organizations, with server certificates generated by many
62 1.1 lukem different CAs. As such, a client is likely to need a list of
63 1.1 lukem many different trusted CAs in its configuration.
64 1.1 lukem
65 1.1 lukem H3: Server Configuration
66 1.1 lukem
67 1.1 lukem The configuration directives for slapd belong in the global directives
68 1.1 lukem section of {{slapd.conf}}(5).
69 1.1 lukem
70 1.1 lukem H4: TLSCACertificateFile <filename>
71 1.1 lukem
72 1.1 lukem This directive specifies the {{TERM:PEM}}-format file containing
73 1.1 lukem certificates for the CA's that slapd will trust. The certificate for
74 1.1 lukem the CA that signed the server certificate must be included among
75 1.1 lukem these certificates. If the signing CA was not a top-level (root) CA,
76 1.1 lukem certificates for the entire sequence of CA's from the signing CA to
77 1.1 lukem the top-level CA should be present. Multiple certificates are simply
78 1.1 lukem appended to the file; the order is not significant.
79 1.1 lukem
80 1.1 lukem H4: TLSCACertificatePath <path>
81 1.1 lukem
82 1.1 lukem This directive specifies the path of a directory that contains
83 1.1 lukem individual {{TERM:CA}} certificates in separate files. In addition,
84 1.1 lukem this directory must be specially managed using the OpenSSL {{c_rehash}}
85 1.1 lukem utility. When using this feature, the OpenSSL library will attempt to
86 1.1 lukem locate certificate files based on a hash of their name and serial number.
87 1.1 lukem The {{c_rehash}} utility is used to generate symbolic links with the
88 1.1 lukem hashed names that point to the actual certificate files. As such,
89 1.1 lukem this option can only be used with a filesystem that actually supports
90 1.1 lukem symbolic links. In general, it is simpler to use the
91 1.1 lukem {{EX:TLSCACertificateFile}} directive instead.
92 1.1 lukem
93 1.1.1.5 tron When using Mozilla NSS, this directive can be used to specify the
94 1.1.1.5 tron path of the directory containing the NSS certificate and key database
95 1.1.1.5 tron files. The {{certutil}} command can be used to add a {{TERM:CA}} certificate:
96 1.1.1.5 tron
97 1.1.1.5 tron > certutil -d <path> -A -n "name of CA cert" -t CT,, -a -i /path/to/cacertfile.pem
98 1.1.1.5 tron
99 1.1.1.5 tron . This command will add a CA certficate stored in the PEM (ASCII) formatted
100 1.1.1.5 tron . file named /path/to/cacertfile.pem. {{EX:-t CT,,}} means that the certificate is
101 1.1.1.5 tron . trusted to be a CA issuing certs for use in TLS clients and servers.
102 1.1.1.5 tron
103 1.1 lukem H4: TLSCertificateFile <filename>
104 1.1 lukem
105 1.1 lukem This directive specifies the file that contains the slapd server
106 1.1 lukem certificate. Certificates are generally public information and
107 1.1 lukem require no special protection.
108 1.1 lukem
109 1.1.1.5 tron When using Mozilla NSS, if using a cert/key database (specified with
110 1.1.1.5 tron {{EX:TLSCACertificatePath}}), this directive specifies
111 1.1.1.5 tron the name of the certificate to use:
112 1.1.1.5 tron
113 1.1.1.5 tron > TLSCertificateFile Server-Cert
114 1.1.1.5 tron
115 1.1.1.5 tron . If using a token other than the internal built in token, specify the
116 1.1.1.5 tron . token name first, followed by a colon:
117 1.1.1.5 tron
118 1.1.1.5 tron > TLSCertificateFile my hardware device:Server-Cert
119 1.1.1.5 tron
120 1.1.1.5 tron . Use {{EX:certutil -L}} to list the certificates by name:
121 1.1.1.5 tron
122 1.1.1.5 tron > certutil -d /path/to/certdbdir -L
123 1.1.1.5 tron
124 1.1 lukem H4: TLSCertificateKeyFile <filename>
125 1.1 lukem
126 1.1 lukem This directive specifies the file that contains the private key
127 1.1 lukem that matches the certificate stored in the {{EX:TLSCertificateFile}}
128 1.1 lukem file. Private keys themselves are sensitive data and are usually
129 1.1 lukem password encrypted for protection. However, the current implementation
130 1.1 lukem doesn't support encrypted keys so the key must not be encrypted
131 1.1 lukem and the file itself must be protected carefully.
132 1.1 lukem
133 1.1.1.5 tron When using Mozilla NSS, this directive specifies the name of
134 1.1.1.5 tron a file that contains the password for the key for the certificate specified with
135 1.1.1.5 tron {{EX:TLSCertificateFile}}. The modutil command can be used to turn off password
136 1.1.1.5 tron protection for the cert/key database. For example, if {{EX:TLSCACertificatePath}}
137 1.1.1.5 tron specifes /etc/openldap/certdb as the location of the cert/key database, use
138 1.1.1.5 tron modutil to change the password to the empty string:
139 1.1.1.5 tron
140 1.1.1.5 tron > modutil -dbdir /etc/openldap/certdb -changepw 'NSS Certificate DB'
141 1.1.1.5 tron
142 1.1.1.5 tron . You must have the old password, if any. Ignore the WARNING about the running
143 1.1.1.5 tron . browser. Press 'Enter' for the new password.
144 1.1.1.5 tron
145 1.1 lukem H4: TLSCipherSuite <cipher-suite-spec>
146 1.1 lukem
147 1.1 lukem This directive configures what ciphers will be accepted and the
148 1.1 lukem preference order. {{EX:<cipher-suite-spec>}} should be a cipher
149 1.1 lukem specification for OpenSSL. You can use the command
150 1.1 lukem
151 1.1 lukem > openssl ciphers -v ALL
152 1.1 lukem
153 1.1 lukem to obtain a verbose list of available cipher specifications.
154 1.1.1.2 lukem
155 1.1 lukem Besides the individual cipher names, the specifiers {{EX:HIGH}},
156 1.1 lukem {{EX:MEDIUM}}, {{EX:LOW}}, {{EX:EXPORT}}, and {{EX:EXPORT40}}
157 1.1 lukem may be helpful, along with {{EX:TLSv1}}, {{EX:SSLv3}},
158 1.1 lukem and {{EX:SSLv2}}.
159 1.1 lukem
160 1.1.1.5 tron To obtain the list of ciphers in GnuTLS use:
161 1.1.1.5 tron
162 1.1.1.5 tron > gnutls-cli -l
163 1.1.1.5 tron
164 1.1.1.5 tron When using Mozilla NSS, the OpenSSL cipher suite specifications are used and
165 1.1.1.5 tron translated into the format used internally by Mozilla NSS. There isn't an easy
166 1.1.1.5 tron way to list the cipher suites from the command line. The authoritative list
167 1.1.1.5 tron is in the source code for Mozilla NSS in the file sslinfo.c in the structure
168 1.1.1.5 tron
169 1.1.1.5 tron > static const SSLCipherSuiteInfo suiteInfo[]
170 1.1.1.5 tron
171 1.1 lukem H4: TLSRandFile <filename>
172 1.1 lukem
173 1.1 lukem This directive specifies the file to obtain random bits from when
174 1.1 lukem {{FILE:/dev/urandom}} is not available. If the system provides
175 1.1 lukem {{FILE:/dev/urandom}} then this option is not needed, otherwise a
176 1.1 lukem source of random data must be configured. Some systems (e.g. Linux)
177 1.1 lukem provide {{FILE:/dev/urandom}} by default, while others (e.g. Solaris)
178 1.1 lukem require the installation of a patch to provide it, and others may
179 1.1 lukem not support it at all. In the latter case, EGD or PRNGD should be
180 1.1 lukem installed, and this directive should specify the name of the EGD/PRNGD
181 1.1 lukem socket. The environment variable {{EX:RANDFILE}} can also be used
182 1.1 lukem to specify the filename. Also, in the absence of these options, the
183 1.1 lukem {{EX:.rnd}} file in the slapd user's home directory may be used if
184 1.1 lukem it exists. To use the {{EX:.rnd}} file, just create the file and
185 1.1 lukem copy a few hundred bytes of arbitrary data into the file. The file
186 1.1 lukem is only used to provide a seed for the pseudo-random number generator,
187 1.1 lukem and it doesn't need very much data to work.
188 1.1 lukem
189 1.1.1.5 tron This directive is ignored with GnuTLS and Mozilla NSS.
190 1.1.1.5 tron
191 1.1.1.7 christos H4: TLSDHParamFile <filename>
192 1.1 lukem
193 1.1 lukem This directive specifies the file that contains parameters for
194 1.1 lukem Diffie-Hellman ephemeral key exchange. This is required in order
195 1.1.1.7 christos to use DHE-based cipher suites, including all DSA-based suites (i.e.
196 1.1.1.7 christos {{EX:TLSCertificateKeyFile}} points to a DSA key), and RSA when the 'key
197 1.1.1.7 christos encipherment' key usage is not specified in the certificate. Parameters can be
198 1.1.1.7 christos generated using the following command
199 1.1 lukem
200 1.1 lukem > openssl dhparam [-dsaparam] -out <filename> <numbits>
201 1.1.1.7 christos or
202 1.1.1.7 christos > certtool --generate-dh-params --bits <numbits> --outfile <filename>
203 1.1 lukem
204 1.1.1.7 christos This directive is ignored with Mozilla NSS.
205 1.1.1.5 tron
206 1.1 lukem H4: TLSVerifyClient { never | allow | try | demand }
207 1.1 lukem
208 1.1 lukem This directive specifies what checks to perform on client certificates
209 1.1 lukem in an incoming TLS session, if any. This option is set to {{EX:never}}
210 1.1 lukem by default, in which case the server never asks the client for a
211 1.1 lukem certificate. With a setting of {{EX:allow}} the server will ask
212 1.1 lukem for a client certificate; if none is provided the session proceeds
213 1.1 lukem normally. If a certificate is provided but the server is unable to
214 1.1 lukem verify it, the certificate is ignored and the session proceeds
215 1.1 lukem normally, as if no certificate had been provided. With a setting of
216 1.1 lukem {{EX:try}} the certificate is requested, and if none is provided,
217 1.1 lukem the session proceeds normally. If a certificate is provided and it
218 1.1 lukem cannot be verified, the session is immediately terminated. With a
219 1.1 lukem setting of {{EX:demand}} the certificate is requested and a valid
220 1.1 lukem certificate must be provided, otherwise the session is immediately
221 1.1 lukem terminated.
222 1.1 lukem
223 1.1 lukem Note: The server must request a client certificate in order to
224 1.1 lukem use the SASL EXTERNAL authentication mechanism with a TLS session.
225 1.1 lukem As such, a non-default {{EX:TLSVerifyClient}} setting must be configured
226 1.1 lukem before SASL EXTERNAL authentication may be attempted, and the
227 1.1 lukem SASL EXTERNAL mechanism will only be offered to the client if a valid
228 1.1 lukem client certificate was received.
229 1.1 lukem
230 1.1 lukem H3: Client Configuration
231 1.1 lukem
232 1.1 lukem Most of the client configuration directives parallel the server
233 1.1 lukem directives. The names of the directives are different, and they go
234 1.1 lukem into {{ldap.conf}}(5) instead of {{slapd.conf}}(5), but their
235 1.1 lukem functionality is mostly the same. Also, while most of these options may
236 1.1 lukem be configured on a system-wide basis, they may all be overridden by
237 1.1 lukem individual users in their {{.ldaprc}} files.
238 1.1 lukem
239 1.1 lukem The LDAP Start TLS operation is used in LDAP to initiate TLS
240 1.1 lukem negotiation. All OpenLDAP command line tools support a {{EX:-Z}}
241 1.1 lukem and {{EX:-ZZ}} flag to indicate whether a Start TLS operation is to
242 1.1 lukem be issued. The latter flag indicates that the tool is to cease
243 1.1 lukem processing if TLS cannot be started while the former allows the
244 1.1 lukem command to continue.
245 1.1 lukem
246 1.1 lukem In LDAPv2 environments, TLS is normally started using the LDAP
247 1.1 lukem Secure URI scheme ({{EX:ldaps://}}) instead of the normal LDAP URI
248 1.1 lukem scheme ({{EX:ldap://}}). OpenLDAP command line tools allow either
249 1.1 lukem scheme to used with the {{EX:-H}} flag and with the {{EX:URI}}
250 1.1 lukem {{ldap.conf}}(5) option.
251 1.1 lukem
252 1.1 lukem
253 1.1 lukem H4: TLS_CACERT <filename>
254 1.1 lukem
255 1.1 lukem This is equivalent to the server's {{EX:TLSCACertificateFile}} option. As
256 1.1 lukem noted in the {{SECT:TLS Configuration}} section, a client typically
257 1.1 lukem may need to know about more CAs than a server, but otherwise the
258 1.1 lukem same considerations apply.
259 1.1 lukem
260 1.1 lukem H4: TLS_CACERTDIR <path>
261 1.1 lukem
262 1.1 lukem This is equivalent to the server's {{EX:TLSCACertificatePath}} option. The
263 1.1 lukem specified directory must be managed with the OpenSSL {{c_rehash}}
264 1.1.1.5 tron utility as well. If using Mozilla NSS, <path> may contain a cert/key database.
265 1.1 lukem
266 1.1 lukem H4: TLS_CERT <filename>
267 1.1 lukem
268 1.1 lukem This directive specifies the file that contains the client certificate.
269 1.1 lukem This is a user-only directive and can only be specified in a user's
270 1.1 lukem {{.ldaprc}} file.
271 1.1 lukem
272 1.1.1.5 tron When using Mozilla NSS, if using a cert/key database (specified with
273 1.1.1.5 tron {{EX:TLS_CACERTDIR}}), this directive specifies
274 1.1.1.5 tron the name of the certificate to use:
275 1.1.1.5 tron
276 1.1.1.5 tron > TLS_CERT Certificate for Sam Carter
277 1.1.1.5 tron
278 1.1.1.5 tron . If using a token other than the internal built in token, specify the
279 1.1.1.5 tron . token name first, followed by a colon:
280 1.1.1.5 tron
281 1.1.1.5 tron > TLS_CERT my hardware device:Certificate for Sam Carter
282 1.1.1.5 tron
283 1.1.1.5 tron . Use {{EX:certutil -L}} to list the certificates by name:
284 1.1.1.5 tron
285 1.1.1.5 tron > certutil -d /path/to/certdbdir -L
286 1.1.1.5 tron
287 1.1.1.5 tron
288 1.1 lukem H4: TLS_KEY <filename>
289 1.1 lukem
290 1.1 lukem This directive specifies the file that contains the private key
291 1.1 lukem that matches the certificate stored in the {{EX:TLS_CERT}}
292 1.1 lukem file. The same constraints mentioned for {{EX:TLSCertificateKeyFile}}
293 1.1 lukem apply here. This is also a user-only directive.
294 1.1 lukem
295 1.1 lukem H4: TLS_RANDFILE <filename>
296 1.1 lukem
297 1.1 lukem This directive is the same as the server's {{EX:TLSRandFile}}
298 1.1 lukem option.
299 1.1 lukem
300 1.1 lukem H4: TLS_REQCERT { never | allow | try | demand }
301 1.1 lukem
302 1.1 lukem This directive is equivalent to the server's {{EX:TLSVerifyClient}}
303 1.1 lukem option. However, for clients the default value is {{EX:demand}}
304 1.1 lukem and there generally is no good reason to change this setting.
305 1.1 lukem
306