Apache 2 LDAP SSL
Paquets debian (pré-requis)
apt-get install apache2 libapache2-mod-php5 libldap-2.4-2 ldap-utils libsasl2-modules-ldap openssl libsasl2-2 libkrb5-3 php5-ldap php5-sasl php5-auth-pam
Configuration Apache
Activer le module LDAP Apache 2.0
a2enmod auth_ldap
Activer le module LDAP Apache 2.2
a2enmod authnz_ldap
Certificat SSL
Copier le certificat dans /etc/apache2/ssl/ldap.pem
-----BEGIN CERTIFICATE-----
KJDFJ
...
JDiejfioe
-----END CERTIFICATE-----
Configuration LDAP dans Apache 2.0
Ajouter dans apache2.conf ou httpd.conf:
LDAPTrustedCA /etc/apache2/ssl/ldap.pem
LDAPTrustedCAType BASE64_FILE
Configuration LDAP dans Apache 2.2
Ajouter dans apache2.conf ou httpd.conf:
LDAPTrustedGlobalCert CA_BASE64 /etc/apache2/ssl/ldap.pem
/etc/ldap/ldap.conf
BASE dc=com
URI ldap://ldap.host.com
TLS_REQCERT demand
TLS_CACERT /etc/apache2/ssl/ldap.pem
Redémarrer le service apache2
/etc/init.d/apache2 restart
Test
ldaptls.php
-
-
<?php
-
$ldap="ldap.myDomain.com";
-
$usr="user@myDomain.com";
-
$pwd="mypassword";
-
$ds=ldap_connect($ldap);
-
$ldapbind=false;
-
if(ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3))
-
if(ldap_set_option($ds, LDAP_OPT_REFERRALS, 0))
-
if(ldap_start_tls($ds))
-
$ldapbind = @ldap_bind($ds, $usr, $pwd);
-
ldap_close($ds);
-
?>
-
Troubleshooting
Problème: fonction PHP ldap_start_tls en erreur. Authentification LDAP impossible par la suite.
Système: debian lenny
Nom du paquet: apache2
Version: 2.2.9-10
Solution:
cd /etc/ldap
mkdir certs
cp /etc/apache2/ssl/ldap.pem /etc/ldap/certs/mycert.pem
vi /etc/ldap/ldap.conf
TLS_REQCERT never
TLS_CACERT /etc/ldap/certs/mycert.pem
/etc/init.d/apache2 restart
Autres articles susceptibles de vous intéresser :
Tags: Apache, LDAP, SSL
Posted in App | No Comments »
