Howtos:Configurer SSL sur Debian Lenny/fr
From OCS Inventory NG
Contents |
Configuration de SSL sur Apache
Activer le mode SSL
a2enmod ssl
Si la commande est bien prise en compte, ce message doit apparaitre :
Enabling module ssl. See /usr/share/doc/apache2.2-common/README.Debian.gz on how to configure SSL and create self-signed certificates. Run '/etc/init.d/apache2 restart' to activate new configuration!
Déclaration du VirtualHost
Création du fichier /etc/apache2/sites-available/ssl avec le contenu suivant :
#NameVirtualHost *:443
<VirtualHost nunux.home:443>
ServerAdmin moi@monfai.com
ServerName nunux.home
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
SSLEngine On
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateKeyFile /etc/apache2/ssl/server.key
SSLCertificateFile /etc/apache2/ssl/server.crt
CustomLog /var/log/apache2/access.log combined
ServerSignature On
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
Création des clés SSL publique et privée
openssl genrsa -des3 -out server.key 1024
Si la commande est bien prise en compte, une passphrase vous est demandée :
Generating RSA private key, 1024 bit long modulus .................++++++ .........++++++ e is 65537 (0x10001) Enter pass phrase for ardonroyan.key: salut Verifying - Enter pass phrase for ardonroyan.key:salut
Fixer la configuration
Enregistrer la passphrase dans le fichier pour ne pas avoir à la renseigner à chaque boot :
mv server.key server-old.key openssl rsa -in server-old.key -out server.key
Si la commande est bien prise en compte, la passphrase vous est demandée :
Enter pass phrase for ardonroyan-old.key: salut writing RSA key
Création du certificat
openssl req -new -key server.key -out server.csr
Vous devez répondre aux questions ci-dessous :
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) [AU]:FR
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:MAVILLE
Organization Name (eg, company) [Internet Widgits Pty Ltd]:MABOITE
Organizational Unit Name (eg, section) []:
Common Name (eg, YOUR name) []:
Email Address []:moi@monFAI.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: <<<<------- vous n'êtes pas obligé de spécifier un mot de passe (ENTREE pour continuer)
An optional company name []:
Auto-signature du certificat
openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt
Si la commande est bien prise en compte, ce message apparait :
Signature ok subject=/C=FR/ST=Some State/L%3DMAVILLE/O%3DMABOITE/emailAddress%3Dmoi@monFAI.com State/L=MAVILLE/O=MABOITE/emailAddress=moi@monFAI.com Getting Private key
Mise en place du certificat
On place ces 2 fichiers dans le sous-répertoire d'apache précédemment créé :
mkdir /etc/apache2/ssl cp server.crt /etc/apache2/ssl/ cp server.key /etc/apache2/ssl/
Activation du VirtualHost SSL
On active le VirtuaHost
a2ensite ssl
On redémarre apache et on teste avec https://IP_Serveur
/etc/init.d/apache2 restart