LDAP System Administration

Home > Other > LDAP System Administration > Page 7
LDAP System Administration Page 7

by Gerald Carter


  sasl-secprops noplain,noanonymous,minssf=56

  Comparing the value of sasl-secprops with the mechanisms listed in Table 3-4 shows that your server will allow only the following mechanisms for authentication:

  DIGEST-MD5

  GSSAPI

  KERBEROS_4

  This configuration assumes that all of these SASL plug-ins have been installed as well. Also remember that configuring these SASL parameters does not require that an SASL mechanism must always be used for authentication.

  SSL/TLS Options

  Like the SASL parameters, slapd.conf offers several options for configuring settings related to SSL and TLS. These parameters include:

  TLSCipherSuite cipher-suite-specification

  TLSCertificateFile filename

  TLSCertificateKeyFile filename

  The TLSCipherSuite parameter allows you to specify which ciphers the server will accept. It also specifies a preference order for the ciphers. The value for TLSCipherSuite should be a colon-separated list of cipher suites. The explanation of available cipher suites is lengthy, so I won't reproduce it; refer to the ciphers(1) manpage distributed with OpenSSL. Here are a few common options; the order of preference is from left to right:

  RC4:DES:EXPORT40

  HIGH:MEDIUM

  3DES:SHA1:+SSL2

  The next two parameters, TLSCertificateFile and TLSCertificateKeyFile , inform slapd of the location of the server's certificate and the associated private key. This will be used to implement both LDAP over SSL (LDAPS) and the StartTLS extended operation. However, you have yet to create a certificate for your server.

  Generating the server's certificate

  The CA.pl Perl script, installed in /usr/local/misc/ as part of the OpenSSL installation, provides a nice wrapper around the openssl tool and its command-line arguments. To use this script, openssl must be located in the current search path.

  * * *

  Crypto 101

  In my own work configuring OpenSSL and the services that use these libraries, I have found the documentation a little sparse. If you are interested in learning more about SSL, cryptography, or digital certificates, the following sources are a good place to start:

  "An Introduction to SSL," http://developer.netscape.com/docs/manuals/security/sslin/content.htm.

  T. Dierks, et al., "The TLS Protocol Version 1.0", RFC2246, January 1999.

  C. Kaufman, et al., Network Security: PRIVATE Communication in a PUBLIC World (Prentice Hall).

  Peter Gutmann's "Godzilla Crypto Tutorials Slides," http://www.cs.auckland.ac.nz/~pgut001/.

  Bruce Schneier, Applied Cryptography: Protocols, Algorithms, and Source Code in C (John Wiley & Sons).

  John Viéga, et al., Network Security with OpenSSL (O'Reilly).

  * * *

  The CA.pl script greatly simplifies the creation of server certificates. In order to create a new certificate, use the -newcert command-line option and answer the questions as prompted. Here's how to use CA.pl to create a new certificate:

  $ /usr/local/misc/CA.pl -newcert

  Enter PEM pass phrase:test

  Verifying password - Enter PEM pass phrase:test

  -----

  You are about to be asked to enter information that will be incorporated into your

  certificate request.

  What you are about to enter is what is called a Distinguished Name or a DN.

  There are quite a few fields but you can leave some blank

  For some fields there will be a default value,

  If you enter '.', the field will be left blank.

  -----

  Country Name (2 letter code) [GB]:US

  State or Province Name (full name) [Berkshire]:Alabama

  Locality Name (eg, city) [Newbury]:Somewhere

  Organization Name (eg, company) [My Company Ltd]:PlaineJoe Dot Org

  Organizational Unit Name (eg, section) [ ]:IT

  Common Name (eg, your name or your server's hostname) [ ]:pogo.plainjoe.org

  Email Address [ ]:[email protected]

  Certificate (and private key) is in newreq.pem

  This command creates a file named newreq.pem that contains a password-protected private key and a self-signed certificate. Here are the contents of newreq.pem:

  -----BEGIN RSA PRIVATE KEY-----

  Proc-Type: 4,ENCRYPTED

  DEK-Info: DES-EDE3-CBC,D8851189E7EA85CE

  ImZpOfzqhNhNa6MRQBtYxjPbWmHw+3XxVAowO1FJyFQRQhuRDqrUia1IW7Tikb4d

  rvjbv8T1+SN9vRGWBpz3nAERnS6uEnzPu201b9X413uXaF80TYYId7OUalG5mjqr

  GG0oHaYwbmvAIRyhq3zhqCnBgscZ0l5DCXGTw0T1TeqaTfD8BpRE4ES+F0dlKjRf

  yXuXmLrTg0C9ITokzRj4Xtu0nJfQ5LKouooeI43FHqFBFV4Jw5IIKOuAg/tkinez

  VqVesaV707PLqdlYNAVx26z/nPwbbAT2JY4fqemBzjBJPDN6Tr/QncYgbMcG+H5/

  7z7mBmOWq7nCpgFSwV1KgvtDIOjqZmGSpTLbZ/pY+JUT3iPsRAaL5XHDZDM6pF0l

  R70ePd3Z5sUcg1TJlnuPYejyTi1OM/hoKrNnj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lWSD9aGC9rMaMGrxG5YqI+dEuhbGWhnVo37IsMlHC+oJsXwY/2

  r/RQT5dk1jyC4qt+2r4mGGC/QbCX0GRjT0gn3obB570XZ19qBCfYwIXOtYncIX0P

  0fUwFVRG5frBL5QDAgMBAAGjgf0wgfowHQYDVR0OBBYEFPVRTbSjVJ4v4pOb0N0k

  oJk8YZIGMIHKBgNVHSMEgcIwgb+AFPVRTbSjVJ4v4pOb0N0koJk8YZIGoYGjpIGg

  MIGdMQswCQYDVQQGEwJVUzEQMA4GA1UECBMHQWxhYmFtYTESMBAGA1UEBxMJU29t

  ZXdoZXJlMRowGAYDVQQKExFQbGFpbmVKb2UgRG90IE9yZzELMAkGA1UECxMCSVQx

  HDAaBgNVBAMTE2dhcmlvbi5wbGFpbmpvZS5vcmcxITAfBgkqhkiG9w0BCQEWEmpl

  cnJ5QHBsYWluam9lLm9yZ4IBADAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUA

  A4GBAIM+ySiITRXb/d1qcO/XUQSKdU3IXqPgS8jY3U12Bll/kCZFcZxjksg6xBib

  91Y/bonSEisJG74zn/0ts3sjsr3QKZp5xFcYCyK3IYjaqnFeAOh+eUp54vLpmQZX

  e4QaeTkg/8MnS3vFvWoxfo4Z1Zu/wWhp9WMRRwIVAR99Ppps

  -----END CERTIFICATE-----

  Notice that the CA.pl script places a private key in the same file as the public certificate. You must remove the password for the private key unless you always want to start the OpenLDAP server manually. It is extremely important to protect this key carefully. Public key cryptography is no good if the private key is readily available to anyone.

  Because this private key is password protected, it will require some modification before integrating it into the server's setup. The following command removes the password from the private key and places the modified version of the key in a separate file:

  $ openssl rsa -in newreq.pem -out newkey.pem

  read RSA key

  Enter PEM pass phrase:test

  writing RSA key

  The newkey.pem file can be renamed to a filename of your choosing. Something like slapd-key.pem would be appropriate. Make sure that the new file is safely secured using the appropriate filesystem permissions (i.e., rw-------).

  Finally, using your favorite text editor, remove the original private key from n
ewreq.pem. I'll rename the certificate file to slapd-cert.pem for the remaining examples in this chapter. At this point, we have the following files:

  slapd-key.pem

  LDAP server's private key

  slapd-cert.pem

  LDAP server's public certificate

  Here are the TLS configuration parameters in the context of slapd.conf:

  # /usr/local/etc/openldap/slapd.conf

  # Global section

  ## Include the minimum schema required.

  include /usr/local/etc/openldap/schema/core.schema

  ## Added logging parameters

  loglevel 296

  pidfile /usr/local/var/slapd.pid

  argsfile /usr/local/var/slapd.args

  ## TLS options for slapd

  TLSCipherSuite HIGH

  TLSCertificateFile /etc/local/slapd-cert.pem

  TLSCertificateKeyFile /etc/local/slapd-key.pem

  #######################################################

  ## Database sections omitted

  More Security-Related Parameters

  There are also five other security-related global options to be covered prior to continuing on to the database section. These are:

  security

  require

  allow

  disallow

  password-hash

  The security parameter allows us to specify general security strength factors. Table 3-5 lists the options and values for the security parameter. All of these options take an integer value specifying the strength factor; the integer must be one of the values used for the minssf and maxssf parameters described in Table 3-3.

  Table 3-5. Possible values for the slapd.conf security parameter

  Value

  Description

  sasl

  Defines the SASL security strength factor.

  ssf

  Defines the overall security strength factor.

  tls

  Defines the security strength factor to the SSL/TLS security layer.

  transport

  Defines the security strength provided by the underlying transport layer. Eventually, this option will be used to choose between multiple secure transport layer protocols, such as TLS and IPSEC.

  update_sasl

  update_ssf

  update_tls

  update_transport

  Define the security strength of the various layers when performing update operations on the directory.

  For example, we can require very strong authentication and transport layer security when performing updates by adding the following line to the global section of slapd.conf:

  ## Require strong authentication and transport layer security for update operations.

  ## NOTE: This is just an example and will not be added to our final slapd.conf.

  security update_sasl=128,update_tls=128

  To take full advantage of the security parameter, you must disable simple binds and use only SASL mechanisms for authentication. See the disallow parameter in this section for details of how this can be done.

  The require parameter differs from the security parameter by allowing an administrator to define general conditions that must be met to provide access to the directory. This setting may be done globally or on a per-database basis. The require parameter accepts a comma-separated list of the strings described in Table 3-6.

  Table 3-6. Values for the require parameter

  Value

  Description

  none

  Clears all requirements.

  authc

  Requires client authentication prior to directory access (i.e., no anonymous access).

  bind

  Requires the client to issue a bind request, possibly an anonymous bind, prior to directory operations.

  LDAPv3

  Requires the client to use Version 3 of the LDAP protocol for directory access. By default, OpenLDAP supports both LDAPv2 and v3 clients.

  SASL strong

  Require the client to use strong (SASL) authentication in order to be granted access to the directory. Currently, these two options are identical.

  The effect of some of the require settings can be obtained by other means as well. For example, if anonymous users should have no access to directory information, OpenLDAP provides access control lists within a database that can restrict access in a much more flexible way.

  The allow (and complementary disallow) parameters provide another means of enabling and disabling certain features. Currently, the allow parameter supports only two options:

  none

  This is the default setting.

  tls_2_anon

  Allows TLS to force the current session to anonymous status.

  The disallow parameter, however, offers many more options. These include:

  bind_v2

  Disables LDAPv2 bind requests

  bind_anon

  Disables anonymous binds

  bind_anon_cred

  Disables anonymous credentials when the DN is empty

  bind_anon_dn

  Disables anonymous binds when the DN is nonempty

  bind_simple

  Disables simple binds

  bind_krbv4

  Disables Kerberos 4 bind requests

  tls_authc

  Disables StartTLS if the client is authenticated

  Finally, the password-hash parameter defines the default password encryption scheme used to store values in the userPassword attribute. This setting can be overridden on an individual attribute basis by prefixing the password with the appropriate directive. The default encryption scheme is {SSHA}. Other possibilities include:

  {SHA}

  {SMD5}

  {MD5}

  {CRYPT}

  {CLEARTEXT}

  The security parameters and examples presented here are enough for our needs. Refer to the openssl(1) manpage for more information on OpenSSL tools and configuration.

  After covering these final parameters, you can complete the global section of your slapd.conf:

  # /usr/local/etc/openldap/slapd.conf

  # Global section

  ## Include the minimum schema required.

  include /usr/local/etc/openldap/schema/core.schema

  ## Added logging parameters

  loglevel 296

  pidfile /usr/local/var/slapd.pid

  argsfile /usr/local/var/slapd.args

  ## TLS options for slapd

  TLSCipherSuite HIGH

  TLSCertificateFile /etc/local/slapd-cert.pem

  TLSCertificateKeyFile /etc/local/slapd-key.pem

  ## Misc security settings

  password-hash {SSHA}

  #######################################################

  ## Database sections omitted

  Serving Up Data

  Following the global section of slapd.conf will be one or more database sections, each defining a directory partition. A database section begins with the database directive and continues until the next occurrence of the database directive or the end of the file. This parameter has several possible values:

  bdb

  This backend has been specifically written to take advantage of the Berkley DB 4 database manager. This backend makes extensive use of indexing and caching to speed up performance; it is the recommended backend used on an OpenLDAP server.

  ldbm

  An ldbm database is implemented via either the GNU Database Manager or the Sleepycat Berkeley DB software package. This backend is the older implementation of the bdb backend. The details of this backend are described in the slapd-ldbm(5) manpage.

  passwd

  The passwd backend is a quick and dirty means of providing a directory interface to the system passwd(5) file. It has only one configuration parameter: the file directive, which defines the location of the password file (if different from /etc/passwd) used to respond to directory queries. The details of this backend are described in the slapd-passwd(5) manpage.

  shell

  The shell backend di
rective allows the use of alternative (and external) databases. This directive lets you specify external programs that are called for each of the LDAPv3 core operations. The details of this backend are described in the slapd-shell(5) manpage.

  The first step in writing a database section is defining the type of backend. The examples in the remainder of this book almost exclusively use the bdb database value.

  ## Begin a new database section.

  database bdb

  The next item is to define the directory partition's naming context. The naming context allows slapd to serve multiple, potentially disconnected partitions from a single server. Each partition has a unique naming context that identifies the root entry in the tree. The following example defines the naming context of the database to correspond with the local domain name, a practice recommended by RFC 2247 ("Using Domains in LDAP/X.500 Distinguished Names"):

  ## Define the beginning of example database.

  database bdb

  ## Define the root suffix you serve.

  suffix "dc=plainjoe,dc=org"

  Each LDAP directory can have a root DN (rootdn), which is similar to the superuser account on Unix systems. When authenticated, this DN is authorized to do whatever the user desires; access control restrictions do not apply. For this reason, some administrators prefer not to configure a root DN at all, or at least remove it once the directory has been sufficiently populated to hand over control to existing user accounts.

  The naming of the root DN is arbitrary, although the cn values of "admin" and "Manager" have become common choices. The root DN also requires a corresponding root password (rootpw), which can be stored in clear text or encrypted form using one of the prefixes accepted by the password-hash parameter. OpenLDAP 2 provides the slappasswd(8c) utility for generating {CRYPT} , {MD5}, {SMD5}, {SSHA}, and {SHA} passwords. Do not place the root password in plain text regardless of what the permissions on slapd.conf are. Even if the password is encrypted, it is extremely important not to allow unauthorized users to view slapd.conf.

 

‹ Prev