Un mémo sur comment changer le niveau de chiffrement des certificats auto-signés en 4096 bits car par défaut, sous Yunohost les certificats sont générés en 2048 bits.
A savoir : depuis la version 2.5 de Yunohost il est possible de générer des certificats reconnus avec l’aide de Let’s Encrypt mais je n’ai pas réussi à les utiliser avec OpenVPN. C’est pour cette raison, je vais utiliser les certificats auto-signé de Yunohost pour le VPN.
Certificats auto-signé en 4096 bits sous Yunohost
- Remplacer 2048 par 4096 dans les fichiers openssl.ca.cnfetopenssl.cnf, qui se trouvent dans le répertoire/usr/share/yunohost/yunohost-config/ssl/yunoCA:
cd /usr/share/yunohost/yunohost-config/ssl/yunoCA sed -i "s/2048/4096/g" openssl.cnf sed -i "s/2048/4096/g" openssl.ca.cnf
- Création du script :
cd ~ nano createcert.sh
NB : remplacer vpn.domaine.tld par votre domaine.
# Sauvegarde du répertoire SSL de YunoHost, pour la lisibilité
ssldir=/usr/share/yunohost/yunohost-config/ssl/yunoCA
# Sauvegarde du chemin final SSL (ne pas oublier de modifier avec votre domaine)
finalpath=/etc/yunohost/certs/vpn.domaine.tld
# Sauvegarde du numéro de série du nouveau certificat
serial=$(cat "$ssldir/serial")
# Sauvegarde du certificat actuel du domaine
cp -a $finalpath $finalpath.back
# Suppression des certificats et des fichiers de configuration
rm $finalpath/{crt.pem,key.pem,openssl.cnf}
# Copie du fichier de configuration d’openSSL
cp $ssldir/openssl.cnf $finalpath/
# Changement de la configuration yunohost.org avec votre domaine
# NE PAS OUBLIER DE REMPLACER vpn.alphasek.one !
sed -i "s/yunohost.org/vpn.domaine.tld/g" $finalpath/openssl.cnf
# Generation du certificat et de la clé
openssl req -new -config $finalpath/openssl.cnf -days 3650 -out $ssldir/certs/yunohost_csr.pem -keyout $ssldir/certs/yunohost_key.pem -node$
# Signature du certificat avec le CA du serveur
openssl ca -config $finalpath/openssl.cnf -days 3650 -in $ssldir/certs/yunohost_csr.pem -out $ssldir/certs/yunohost_crt.pem -batch
# Copie du certificat et de la clé au bon endroit
cp $ssldir/newcerts/$serial.pem $finalpath/crt.pem
cp $ssldir/certs/yunohost_key.pem $finalpath/key.pem
# Réparation des permissions
chmod 755 $finalpath
chmod 640 $finalpath/key.pem $finalpath/crt.pem
chmod 600 $finalpath/openssl.cnf
# Autoriser metronome à accéder aux certificats
chown root:metronome $finalpath/key.pem $finalpath/crt.pem
chmod +x createcert.sh
./createcert.sh
Generating a 4096 bit RSA private key
...............................................++
..................................................................................................................................................++
writing new private key to '/usr/share/yunohost/yunohost-config/ssl/yunoCA/certs/yunohost_key.pem'
-----
Using configuration from /etc/yunohost/certs/vpn.domaine.tld/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number: 20 (0x14)
        Validity
            Not Before: Feb  3 11:51:47 2017 GMT
            Not After : Feb  1 11:51:47 2027 GMT
        Subject:
            commonName                = vpn.domaine.tld
        X509v3 extensions:
            X509v3 Basic Constraints: 
                CA:FALSE
            Netscape Comment: 
                OpenSSL Generated Certificate
            X509v3 Subject Key Identifier: 
                ****************************************
            X509v3 Authority Key Identifier: 
                keyid:**************************************
            X509v3 Key Usage: 
                Digital Signature, Non Repudiation, Key Encipherment
            X509v3 Subject Alternative Name: 
                DNS:vpn.domaine.tld, DNS:www.vpn.domaine.tld, DNS:ns.domaine.tld
Certificate is to be certified until Feb  1 11:51:47 2027 GMT (3650 days)
Write out database with 1 new entries
Data Base Updated
Source du script : https://yunohost.org/#/regenerate_certificate_fr
 
  
 