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