User Tools

Site Tools


en:vpn:renew-cert

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
en:vpn:renew-cert [2019/10/13 15:01] – external edit 127.0.0.1en:vpn:renew-cert [2020/12/05 18:07] hgo
Line 1: Line 1:
-====== Renouvellement du certificat ======+# Renewal of VPN certificate
  
-TODOrefaire les images +If you have issues connecting to the VPN and you see the error
- +``
-Si je ne me trompe ces méthodes sont reprisent dans l'application [neutrinet_ynh](https://github.com/Neutrinet/neutrinet_ynh). +Certificate has key usage  00a0, expects 00a0 
-Pour mettre à jour cette application : +``
- +in `/var/log/openvpn-client.log`, then your certificate has probably expired.
-`$ sudo yunohost app upgrade neutrinet -u https://github.com/Neutrinet/neutrinet_ynh+
- +
-Si non, et que vous voyez l'erreur `Certificate has key usage  00a0, expects 00a0` dans le fichier `/var/log/openvpn-client.log`, votre certificat a probablement expiré. +
-Pour vérifier sa date d'expiration, en tant que `root`:+
  
 +To check its expiry date, as `root` type the command:
 ```sh ```sh
-$ openssl x509 -in /etc/openvpn/keys/user.crt -enddate+$ openssl x509 -in /etc/openvpn/keys/user.crt -noout -enddate
 notAfter=Nov 12 13:42:43 2018 GMT notAfter=Nov 12 13:42:43 2018 GMT
------BEGIN CERTIFICATE----- 
-... 
------END CERTIFICATE----- 
 ``` ```
 +The displayed date after `noAfter` is the expiry date.
  
-La date affichée après le `noAfter` est la date d'expiration +There are four methods to renew the certificate.
  
-Il y a trois procédures possibles pour renouveler le certificat.+## 1Neutrinet app
  
-# Directement à partir d'une brique+The [[en:cube:apps-neutrinet|Neutrinet app]] takes care of checking every night whether certificates must be renewed.
  
-Pour le renouveler, en tant que `root`:+### Install
  
 +You can either install the app through the admin panel, or with:
 ```sh ```sh
-$ cd /opt/neutrinet/renew_cert +yunohost app install neutrinet
-$ ve/bin/python renew_from_cube.py+
 ``` ```
  
-Procédure par le script Renew_cert de Bram +### Upgrade
  
-La procédure est donc de cloner le dépôt git sur ton cubie board, ou d'ailleurs sur n'importe quel ordinateur:+To upgrade this app: 
 +```sh 
 +yunohost tools update --apps 
 +yunohost tools upgrade --apps neutrinet 
 +```
  
-`git clone https://github.com/neutrinet/renew_cert`+## 2From a cube
  
-(dans le dossier qui te convient le mieux) +If the Neutrinet app is already installed, you can force the certificates verification: 
-Et tu rentres dans le sous-dossier qui vient d'être créé:+```sh 
 +cd /opt/neutrinet/renew_cert 
 +./renew_cert_cron.sh -
 +```
  
-`cd renew_cert`+## 3. From the renew_cert script
  
-Ensuitetu crées un environnement virtuel python (ce qui veut dire que les paquets pythons que tu installeras n'affecteront pas le reste de ton système) :+Clone the following git repositoryeither on your cube or your own computer: 
 +```sh 
 +git clone https://git.domainepublic.net/Neutrinet/renew_cert 
 +```
  
-`virtualenv ve`+Move to the folder that just has been created: 
 +```sh 
 +cd renew_cert 
 +```
  
-Puis, tu actives cet environnement:+Create a virtual python3 environment. This means that the installed python3 packages won't have any impact on the rest of the system: 
 +```sh 
 +python3 -m venv ve 
 +```
  
-`source ve/bin/activate`+Enable this environment: 
 +```sh 
 +source ve/bin/activate 
 +```
  
-Enfin, tu installes les dépendances du script (peut faire une petite erreur sur Jessie, mais fonctionne quand même):+Install the script dependencies: 
 +``` 
 +pip install -r requirements.txt 
 +```
  
-`pip install -r requirements.txt+Finally, run the script with this command: 
- +``` 
-Pour finir, tu peux enfin lancer le script en lui-même en tapant cette commande+python renew.py <Neutrinet VPN's username> 
 +```
  
- `python renew_local.py TON-NOM-D'UTILISATEUR-NEUTRINET TON-MOT-DE-PASSE`+You will be asked for your password to login to the Neutrinet VPN.
  
-Je te conseillerais de mettre un espace avant cette commandeet ce afin d'éviter qu'elle ne se trouve dans ton historique de commandes.état +Normalya subfolder named `certs_YYYY-MM-DD_HH:MM:SS` (replace the uppercase letters with the script execution date and time ) should be createdwhich contains all the configuration files needed for the OpenVPN client.
-Le script prendra quelques minutest'informant des différentes étapes qu'il passe (Login, Get client data, Generate new cert using openssl, See if I already have a cert, I already have a cert, let's update it, Put new cert online et enfin Download new config si tout s'est bien passé).+
  
-Tu auras alors dans le dossier renew_cert, un sous-dosser appelé certs_2017-07-xx_XX:XX:XX (ou les derniers X dépendant de la date et l'heure d'exécution du script), qui reprend tous les fichiers de configuration demandé par ton client openvpn.+The files that we need are `client.crt` and `client.key`, i.e. the public and private key of the certificate.
  
-Ce sont essentiellement les fichiers client.crt et client.key qui t'intéresse, et qui doivent remplacer les fichiers du même nom situé (pour autant que tu utilises la configuration standard openvpn de Debian), dans /etc/openvpn/ ou dans /etc/openvpn/neutrinet +These files must replace the files in `/etc/openvpn` (this may change depending of the OS). 
-Avant de remplacer l'un par l'autre, je suggèrerais de faire une copie des anciens, au cas où. +On the cube, these files are in `/etc/openvpn/keys`
-Cela donnerait quelque chose comme (toujours en étant dans le dossier renew_cert):+
  
 +**Remark**: Before replacing one with the other, it is advisable to make a backup of the old certificate, just in case. For instance, with the following commands (still from the `renew_cert` directory):
 ```sh ```sh
-sudo mv /etc/openvpn/neutrinet/client.crt /etc/openvpn/neutrinet/client.crt.backup +sudo mv /etc/openvpn/keys/user.crt{,.backup} 
-sudo mv /etc/openvpn/neutrinet/client.key /etc/openvpn/neutrinet/client.key.backup +sudo mv /etc/openvpn/keys/user.key{,.backup} 
-sudo mv client.crt /etc/openvpn/neutrinet/client.crt +sudo mv client.crt /etc/openvpn/keys/user.crt 
-sudo mv client.key /etc/openvpn/neutrinet/client.key+sudo mv client.key /etc/openvpn/keys/user.key
 ``` ```
  
-OU (apparement dans centains cas -à définir- userremplace client.)+All you need to do is to restart the OpenVPN service to check if it's still working.
  
 +**Remark**: Ideally, make sure to be connected on the same local network as your cube, i.e. through its local address (192.168.1.x in most cases).
 +```sh
 +sudo systemctl restart openvpn`
 ``` ```
-sudo mv /etc/openvpn/neutrinet/user.crt /etc/openvpn/neutrinet/user.crt.backup + 
-sudo mv /etc/openvpn/neutrinet/user.key /etc/openvpn/neutrinet/user.key.backup +To check that you are connected to the VPN, you can run the following command: 
-sudo mv user.crt /etc/openvpn/neutrinet/user.crt +```sh 
-sudo mv user.key /etc/openvpn/neutrinet/user.key+ip addr
 ``` ```
  
 +Normaly, the `tun0` interface should appear in the list.
  
-Après quoi, il ne te resterait plus qu'à re-démarrer le service VPN pour tester qu'il fonctionne toujours (idéalement, assure-toi de te connecter au cubie localement, via son adresse locale (192.168.1.x dans la plupart des cas).+## 4From user.neutrinet.be
  
 +This method sometimes requires some patience because user.neutrinet.be can produce some failures.
  
-`sudo systemctl restart openvpn`+Login with ssh to your internet cube, then go to the folder where the VPN key is located (it should be the file `/etc/openvpn/keys/user.key`): 
 +```sh 
 +cd /etc/openvpn/keys 
 +```
  
-# Procédure manuelle et via le site user.neutrinet.be+Create a certificate signing request (CSR) for this key: 
 +```sh 
 +openssl req -new -newkey rsa:4096 -nodes -keyout user.key 
 +```
  
-Deuxième méthode (qui parfois demande la patience car actuellement user.neutrinet.be connait des ratés):+You will be asked for several questions, such as the country code (BE), the region (Bruxelles, ...), the organisation, etc... to which the certificate is related. 
 +Most important is the `Cname`, that is the name which will be used by Neutrinet to know to whom belongs the certificate.
  
-La seconde méthode consiste à se connecter en ssh au cubieboard, aller dans le dossier où se trouve la clef du VPN (a priori, il s'agit du fichier /etc/openvpn/neutrinet/client.key ou /etc/openvpn/client.key )+**Remark**: It is recommanded to provide your email address for the Cname field.
  
-`cd /etc/openvpn/neutrinet` +This command create a file named `client.csr`, which contains the certificate signing requestYou can display its content with: 
- +```sh 
-Puis de créer une demande de signature de clefs (CSR) pour cette clef +cat client.csr 
- +```
-`openssl req -new -sha1 -out client.csr -key user.key` +
- +
-Plusieurs questions te seront poséescomme le code pays (BE), la région (Bruxelles, ...), la Société etc... auquel le certificat est attaché. Le plus important est le "Cname", qui est le nom sous lequel tu vas apparaitre pour neutrinet+
- +
-Cette commande créé un fichier client.csr, qui contient la demande de signature. Tu peux en voir le contenu en faisant +
- +
-`cat client.csr`+
  
-Copie ce contenu précieusementet rends-toi sur https://user.neutrinet.be+Copy this contentthen go to https://user.neutrinet.be
  
-Connecte-toi+{{ :fr:vpn:renew_cert-01-login.png?direct&600 |}}
  
-**image**+Login
  
-Clique sur users+{{ :fr:vpn:renew_cert-02-dashboard.png?direct&600 |}}
  
 +Click on `Users`
  
-Attends que cela charge, et quand tu vois ton nom, clique dessus, puis sur "View associated clients"+{{ :fr:vpn:renew_cert-03-users.png?direct&600 |}}
  
 +Wait for the page to load, and when you see your name click on it.
  
-**image**+{{ :fr:vpn:renew_cert-04-user.png?direct&600 |}}
  
-Ensuite clique sur ton certificat (si tu en as plusieurs, il faut utiliser celui qui liste une IPv4 - 80.67.181.x), et choisi l'option "Renew certificate"+Click on `View associated clients`
  
 +{{ :fr:vpn:renew_cert-05-clients.png?direct&600 |}}
  
-**image**+Click on your certificate (if you have more than one, use the one with an IPv4 - 80.67.181.x)
  
-Il va alors te présenter ton certificat actuel. si tu cliquer sur Rekey, tu auras la possibilité de coller le CSR (le fichier généré plus tôt, que tu as copié), puis de cliquer sur Rekey.+{{ :fr:vpn:renew_cert-06-client.png?direct&600 |}}
  
-Une fois cette opération terminée, tu verras un bandeau comme ceci:+Choose the `Renew certificate` option
  
-**image**+{{ :fr:vpn:renew_cert-07-certificate.png?direct&600 |}}
  
-Tu pourras alors cliquer sur "View client details"puis sur Download config package, qui est un zip qui contient le fichier de certificat qu'il faudra remplacer dans, à priori, /etc/openvpn/neutrinet (voir plus haut, en fonction du dossier qui tu as décidé d'utiliser à la configuration du service).+The current certificate should appear on the screen. Click on `Rekey`then paste the content of the CSR (the file you copied earlier).
  
 +Click on the `Rekey` button to confirm.
  
-Voilàc'est tout!+Once this operation doneyou should see the following banner:
  
-# Liens+{{ :fr:vpn:renew_cert-08-rekey.png?direct&600 |}}
  
-- https://github.com/Neutrinet/neutrinet_ynh +You can click on `View client details`, then on `Download config package`.
-- https://github.com/neutrinet/renew_cert+
  
 +This will download a zip file containing the certificate files. In the directory `/etc/openvpn/keys` of your cube, copy the file `client.crt` to `/etc/openvpn/keys/user.crt`.
  
 +That's it!
en/vpn/renew-cert.txt · Last modified: 2022/07/22 13:15 by 127.0.0.1