SSL à l'arrache !
Par Nils le samedi, juillet 19 2008, 15:42 - Linux et Logiciels libres - Lien permanent
Vite fait, mal fait.
Que ceux qui veulent comprendre aillent sur des pages plus complètes, ici je fais juste une petite récap. Alors genre, on a un serveur sur laquelle on veut mettre du HTTPS ou du FTP-SSL. Pas envie d'avoir un "dummy certificate" et pas envie de passer 2 heures sur le sujet. Donc on copie-colle, on répond Yes à tout et c'est torché.
D'abord, openssl.cnf. Il se trouve, selon les distributions, quelque part sous /etc. Sur ma CentOS 5, il est dans "/etc/pki/tls". On fait un petit vi dessus, et on met :
dir = /etc/pki/CA # Where everything is kept certs = $dir/certs # Where the issued certs are kept crl_dir = $dir/crl # Where the issued crl are kept database = $dir/index.txt # database index file. new_certs_dir = $dir/newcerts # default place for new certs.
Un peu plus bas, on modifie la durée de vie du certificat :
default_days = 3650 # how long to certify for
Et pour être encore plus feignasse :
[ req_distinguished_name ] countryName = Country Name (2 letter code) countryName_default = FR countryName_min = 2 countryName_max = 2 stateOrProvinceName = State or Province Name (full name) stateOrProvinceName_default = Ile de France localityName = Locality Name (eg, city) localityName_default = Paris 0.organizationName = Organization Name (eg, company) 0.organizationName_default = Another Home Page organizationalUnitName = Organizational Unit Name (eg, section) organizationalUnitName_default = admin commonName = Common Name (eg, your name or your server\'s hostname) commonName_max = 64 emailAddress = Email Address emailAddress_max = 64
OpenSSL peut faire des alias DNS pour un même certificat, alors on ajoute ça à la fin :
[ALIASES] DNS.1 = www.anotherhomepage.org DNS.2 = mail.anotherhomepage.org
Ensuite, on crée les répertoires et fichiers qui vont bien :
root@thunderbluff:~ #cd /etc/pki
root@thunderbluff:/etc/pki #mkdir -p CA/newcerts
root@thunderbluff:/etc/pki #touch CA/index.txt
root@thunderbluff:/etc/pki #echo 01 > CA/serial
Allez, on génère tout certificat de l'autorité, certificat serveur, clés...:
root@thunderbluff:/etc/pki #cd CA
root@thunderbluff:/etc/pki/CA #openssl req -nodes -new -x509 -keyout thunderbluff-ca.key -out thunderbluff-ca.crt
root@thunderbluff:/etc/pki/CA #openssl req -nodes -new -keyout thunderbluff.key -out thunderbluff.csr
root@thunderbluff:/etc/pki/CA #openssl ca -cert aaron-ca.crt -keyfile thunderbluff-ca.key -out thunderbluff.crt -in thunderbluff.csr
Et puis pour Vsftpd ça peut aider :
root@thunderbluff:/etc/pki/CA #cat thunderbluff.key thunderbluff.crt > thunderbluff.pem
Emballez c'est pesé !



