Apache2 + SSL + LDAP Authentication HOWTO
时间:2006-04-17 来源:huanghaojie
Apache2 + SSL + LDAP Authentication HOWTO
Posted at February 23, 2005 05:20 PM in General .ITS provides a central LDAP server that allows server operators to authenticate users using their Case network ID and password. Talking to the LDAP server using clear text (normal) communication and doing the authentication is relatively easy. However, using this method, users' network usernames and passwords are transmitted over clear text and are susceptible to interception (very unlikely on Case's internal switched network, but possible nonetheless). This document will explain how to set up your web server so it communicates to the LDAP using encryption.
Using SSL to talk to the LDAP is a painful process. LDAP and SSL are very picky when it comes to working together. I learned this the hard way.
1. Compiling and Installing the Programs
- Download Sources
- Install OpenSSL
- tar xvzf openssl-0.9.7e.tar.gz
- cd openssl-0.9.7e
- ./config --prefix=/usr/local/openssl shared
- make
- make install
- ln -s /usr/local/openssl/bin/openssl /usr/local/bin/openssl
- Install OpenLDAP
- tar xvzf openldap-stable-20050125.tgz
- cd openldap-2.2.23
- export CPPFLAGS="-I/usr/local/openssl/include" LDFLAGS="-L/usr/local/openssl/lib"; \
./configure \
--prefix=/usr/local/ \
--sysconfdir=/etc/openldap \
--enable-ipv6 \
--with-tls \
--disable-slurpd \
--disable-slapd \
--with-openssl=/usr/local/openssl - make depend
- make
- make install
- Install Apache 2
- tar xvzf httpd-2.0.53.tar.gz
- cd httpd-2.0.53
- ./configure \
--prefix=/usr/local/apache2 \
--enable-so \
--enable-ssl \
--enable-mods-shared=all \
--with-ssl=/usr/local/openssl \
--enable-ldap \
--enable-auth_ldap \
--with-ldap - make
- make install
- link
- Copy the entrust-chain-cert.pem file to /usr/local/apache2/conf/case.pem
- E-mail [email protected] and ask for an account to do this.
- Add the following anywhere in your httpd.conf file:
LDAPTrustedCAType BASE64_FILE
LDAPTrustedCA /usr/local/apache2/conf/case.pem
- For every <Location> or <Directory> you want protected by LDAP, add the following:
AuthType Basic
AuthName "Case Network ID"
AuthLDAPURL "ldaps://ldap-replica1.cwru.edu/ou=People,o=cwru.edu,o=isp?uid"
AuthLDAPBindDN "DN of special user given to you by ITS"
AuthLDAPBindPassword "Password of the special user given to you"
require valid-user
- Start up Apache
- Visit http://127.0.0.1 to see if the server started
- Make sure that you find:
[notice] LDAP: Built with OpenLDAP LDAP SDK
[notice] LDAP: SSL support available
in the output of /usr/local/apache2/logs/error_log
2. Obtain Case LDAP Certificate
3. Obtain an LDAP DN lookup user
4. Configure Apache to Use LDAP Authentication
5. Pray
6. Post Configuration
You will obviously want to set up Apache to use SSL between the client and the server. Doing this is beyond the scope of this document. Once this is done, it is a good idea to make sure all protected locations on your site are over SSL. A good way to do this is with mod_rewrite. The reason for this is that browsers resend the username and password with every page request.
Another good idea is to set up LDAP query caching. This will speed up page requests because once a client's authenticity has been established, the result of the query will be stored on the server, eliminating any need to connect to the LDAP server. View the mod_ldap documentation for more information. Additionally, you may want to see the mod_auth_ldap documentation for even more configuration options.
Good Luck!