Apache 2 – Régénérer un certificat SSL auto-signé

Suite à l’article de nanard sur les dates de certificats SSL, j’ai reçu des messages d’insultes de ce type:

depth=0 /C=FR
verify error:num=18:self signed certificate
verify return:1
depth=0 /C=FR
verify error:num=10:certificate has expired
notAfter=Feb 23 14:21:23 2010 GMT
verify return:1
depth=0 /C=FR
notAfter=Feb 23 14:21:23 2010 GMT
verify return:1
DONE
notBefore=Jan 24 14:21:23 2010 GMT
notAfter=Feb 23 14:21:23 2010 GMT

Voici comment regénérer un certificat SSL auto-signé:

Connectez-vous en root.

cd /etc/apache2
openssl req -new -x509 -days 365 -key server.key -out server.crt
invoke-rc.d apache2 restart

Et voila !

echo | openssl s_client -connect www.benjaminbaudouin.com:443 | openssl x509 -noout -dates

depth=0 /C=FR/ST=Some-State/O=Internet Widgits Pty Ltd
verify error:num=18:self signed certificate
verify return:1
depth=0 /C=FR/ST=Some-State/O=Internet Widgits Pty Ltd
verify return:1
notBefore=Apr 1 08:03:02 2010 GMT
notAfter=Apr 1 08:03:02 2011 GMT
DONE

App

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


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

App

Recent Tweets

Catégories