Connexion SSL avec certificat auto-signé
Bonjour,
Je cherche depuis des jours (c'est ça d'être noob..:aie:) la solution au problème suivant et je me permets donc de solliciter votre aide :
1- Le problème
Le basculement de la connexion http en https ne s'effectue plus depuis la création/utilisation d'un certificat auto-signé. Le(s) navigateur(s) testés me renvoient invariablement un "Problem Loading page / Unable to connect"
Firebug m'informe que la requete "GET https://www.mon_domaine.fr/index.php?page=100&new_session=a4da9106dba2ffd40345a5eb624d7788" est avortée.
2- Qu'ai-je pu faire comme boulette(s) entre le moment où ça fonctionnait et maintenant ?
Hum de nombreuses possibilités certainement :mrgreen: mais entre autres :
- Modif des accès réseau (Firewall),
- Création d'un certificat auto-signé,
- Basculement php.ini en config de développement pour essayer d'y voir plus clair,
- Modification de la config Apache (vhost avec les nouveaux certificats ssl),
- Relance d'Apache bien sûr.
3- Les symptômes et indications des logs
Bah je n'y vois pas grand chose mais en même temps, je n'y comprends rien..:aie:
ssl_request.log
pas de requête de log ssl depuis les petites modifs ... et ça, c'est super étonnant.
Nota:
Ce log est obtenu par la directive suivante placé dans le vhost:
Code:
1 2
| CustomLog "/mnt/HDA_ROOT/.config/apache/logs/ssl_request.log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r \" %b" |
access.log
Il n'y a que des retours "200" sur les requêtes HTTP, rien sur HTTPS
error.log
J'ai juste ça :
Code:
[Tue Jun 22 14:03:06 2010] [debug] mod_headers.c(665): headers: ap_headers_output_filter()
4- Recherche des causes :
41- Est ce mon navigateur qui avait déjà un certificat de classe 1 pour mon domaine, qui serait "perdu" ..?
=> a priori non, j'ai supprimé ces certif et j'ai aussi essayé avec un autre navigateur et PC qui n'avaient pas ce certificat, mais les symptômes restent les mêmes.
42- Le port 443 serait-il bloqué pour la machine d'accès à mon domaine ..?
Non. Cette machine est autorisée sur les ports 80 et 443 nattés vers ma machine d'hébergement. L'accès en http sur le port 80 s'effectue correctement.
43- Serait-ce Apache qui n'écouterait pas le port 443 ?
Si, la configuration du vhost concerné écoute bien ce port, comme auparavant. Pas de changement ici.
44- ma clé privée ne serait-elle pas accordée avec le certificat auto-signé ?
La création du certificat crt auto-signé avec la clé privée me renvoie un Signature ok
La vérification par openssl x509 -noout -text -in $SERVER_NAME".crt" ne me parle pas vraiment mais je peux la poster le cas échéant..
5- Info: shell de création des clés privées et du certificat crt (voir à partir du step1)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
| #!/bin/sh
# OBJECTIVE: to install a ssh key for connecting via SSL to the webserver
# USE: my_rsa_install.sh <OPTION=0 for CA, OPTION=1 for self generated certificate>
# example of use: my_rsa_install.sh 0
# Nota: do not forget to chmod 700 this shell
# WHAT IT DOES : See each block comments
# Doc-Info: http://slacksite.com/apache/certificate.php
# Written by hornetbzz 20/06/2010
# OPTIONS
# OPTION=0 => certificate to be validated by a CA
# OPTION=1 => Self-validated certificate
# Defaults value
[[ -z $1 ]] && SELFVALIDATED=1
# INIT: pls do not change these datas
SEP="_"
# DATAS to be tuned according to my specific needs
# Self validated certificate validity period (days)
SELF_VALID_PERIOD=365
# can be 1024; 2048, 4096
ENCODING=1024
# Dir name and files
PWD_FILE=/tmp/gen_passwd
DESTINATION_FOLDER=/...../certif_ssl
SSL_CFG=/....../openssl.cnf
SERVER_NAME="server"
BACKUP=$DESTINATION_FOLDER/old
# PREREQUISITES: if these tools are not install, you shall call this function below
# how to check if these packages are already installed : ipkg list_installed | grep package_to_check
function check_ipkg()
{
...
}
# PROMPT "PROCEED FURTHER
# call : proceed_further $msg
function proceed_further()
{
...
}
# Prerequisite required packages: uncomment the line below if you need to install the required packages
#check_ipkg 1
# Check that ssl config file exists
...
# Create cfg folder if not exists
...
# Incremental backup of previous certs files
...
# Generate a pwd file (ideally build several different files. But here, we'll just use the same file twice)
echo "1) Removing old tmp pwd file if existing..."
[[ -f $PWD_FILE ]] && rm $PWD_FILE
i="1 2 3 4 5"
for n in $i
do
pwgen -c -n -y >> $PWD_FILE
done
# remove the EOL using "while" and build a one-line pwd
echo "2) Generating tmp pwd ..."
while read i; do foo=$foo`echo -e $i`; done < $PWD_FILE
echo $foo > $PWD_FILE
# Generate the private key on choice : 1024 to 4096 bits (ie highest possible but depends on your certificate provider requirements)
echo "3) Generating rsa key ..."
openssl genrsa -des3 -rand $PWD_FILE:$PWD_FILE -out $SERVER_NAME".key" $ENCODING
[[ -f $PWD_FILE ]] && rm $PWD_FILE
# Remove passphrase from the private key
echo "4) Removing passphrase from private key ..."
openssl rsa -in $SERVER_NAME".key" -out $SERVER_NAME".pem"
# Generate a CSR file (certificate signing request) to an approved CA
echo "5) Generating csr file ..."
openssl req -new -key $SERVER_NAME".key" -out $SERVER_NAME".csr" -config $SSL_CFG
# alternative 1: openssl req -new -key $SERVER_NAME".pem" -out $SERVER_NAME".csr" -config $SSL_CFG
# alternative 2:openssl req -new -key $SERVER_NAME".key" -out $SERVER_NAME".csr"
# ALERT
echo "6) WARNING: at this stage, pls WRITE DOWN all entered datas and I'd advice you to print a screen shot (ALT ou SHIFT or CTRL+PRINT SCRN)"
proceed_further "Ready to proceed further (Y/n)"
# ASK for CRT file to a CA
echo "7) At this stage you've generated 3 files"
/opt/bin/find -amin -5 -name $SERVER_NAME".*" 2>/dev/null -exec ls -lsth {} \;
[[ $? -eq 1 ]] && echo -e "you shall install better findutils :-) \n" && ls -ltsh $DESTINATION_FOLDER
if [ $SELFVALIDATED -eq 0 ]
then
echo "8) Option "$SELFVALIDATED" choosen : CA validated certificate"
echo -e "\nYou shall now go to your favorite certificate provider (CA) and get back a crt file with the csr file we've just generated"
echo "CA providers example: thawte, verisign, startssl, godaddy ..."
echo "Once you've got back the crt file, pls copy the file to your NAS to "$DESTINATION_FOLDER
else
# Or 2nd option: Generating a Self-Signed Certificate
echo "8) Option "$SELFVALIDATED" choosen : self validated certificate"
[[ $SELFVALIDATED -eq 1 ]] && openssl x509 -req -days $SELF_VALID_PERIOD -in $SERVER_NAME".csr" -signkey $SERVER_NAME".key" -out $SERVER_NAME".crt"
fi
# Check the received certificate
echo "Checking certif validity"
openssl x509 -noout -text -in $SERVER_NAME".crt"
[[ $? -eq 1 ]] && echo "Warning: certif crt issue" && exit
# APACHE DIRECTIVES & VHOST DEFINITION
SSL_DIRECTIVES="AddType application/x-x509-ca-cert .crt \
SSLPassPhraseDialog builtin \n
SSLMutex default \n"
VHOST="SSLRequireSSL\n
SSLEngine on\n
SSLProtocol all -SSLv2 \n
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM \n
SSLSessionCache dbm:/etc/config/apache/logs/ssl_gcache_data \n
SSLSessionCache shm:/etc/config/apache/logs/ssl_gcache_data(512000) \n
SSLCertificateFile /mnt/HDA_ROOT/.config/apache/certif_ssl/ssl.crt\n
SSLCertificateKeyFile /mnt/HDA_ROOT/.config/apache/certif_ssl/ssl.key\n"
echo "9) copy & paste this to your vhost or ssl config file"
echo -e $SSL_DIRECTIVES"\n"
echo -e $VHOST"\n"
proceed_further "Have you copied (Shift+CTRL+C) these directives into your httpd-ssl.conf file (Y/n)"
# Restart Apache
echo "10) Restarting Apache"
/etc/init.d/Qthttpd.sh restart |
6- Les questions auxquelles je n'arrive pas à répondre clairement :
Et évidemment pour lesquelles j'ai cherché dans les forums :aie:.
61- Faut il utiliser la clé privée sans passphrase (.pem)pour générer le certificat auto-signé ?
62- Faut-il aussi inclure la clé server.pem dans la config du vhost Apache ?
63- Faut il supprimer la directive SSLPassPhraseDialog builtin de la config Apache ?
64- Euh Arghhh :cry:, je disjoncte, comment faire ..??
Voila... et merci d'avance