Changes

Line 35: Line 35:     
<ul>
 
<ul>
<li>
+
  <li>Now we'll need to generate TLS certificates that will later be used for authentication purposes when clients connect to the OpenVPN server. For this we'll be using the '''EasyRSA''' application that was installed along with OpenVPN. <br> EasyRSA commands have to be executed via the Windows Command Prompt. It can be opened by typing '''cmd''' in the Windows search bar ('''Windows button + S'''). When you launch it, make sure you run it '''as administrator''': <br>
Now we'll need to generate TLS certificates that will later be used for authentication purposes when clients connect to the OpenVPN server. For this we'll be using the '''EasyRSA''' application that was installed along with OpenVPN. <br> EasyRSA commands have to be executed via the Windows Command Prompt. It can be opened by typing '''cmd''' in the Windows search bar ('''Windows button + S'''). When you launch it, make sure you run it '''as administrator''':
+
 
</li>
   
[[File:How to generate tls certificates windows part 1 v2.png]]
 
[[File:How to generate tls certificates windows part 1 v2.png]]
 +
  </li>
 
----
 
----
<li>
+
  <li>Change the current directory to the EasyRSA folder. To do so, execute this command:
Change the current directory to the EasyRSA folder. To do so, execute this command: <br>
+
    <ul>
<pre>
+
      <pre>cd "C:\Program Files\OpenVPN\easy-rsa"</pre>
cd "C:\Program Files\OpenVPN\easy-rsa"
+
    </ul>
</pre>
+
  </li>
</li>
   
----
 
----
<li>
+
  <li>Initialize the OpenVPN configuration with the following command:
Initialize the OpenVPN configuration with the following command: <br>
+
    <ul>
<pre>
+
      <pre> init-config</pre>
init-config
+
    </ul>
</pre>
+
  </li>
</li>
   
----
 
----
<li>
+
  <li>Open the '''''vars.bat''''' file with the Notepad text editor:
Open the '''''vars.bat''''' file with the Notepad text editor: <br>  
+
    <ul>
<pre>
+
      <pre>notepad vars.bat</pre>
notepad vars.bat
+
    </ul>
</pre>
+
  </li>
</li>
   
----
 
----
<li>
+
  <li>This is the template file for generating certificates, i.e., the information stored here will be offered as default values during certificate generation. Locate and edit the following lines in accordance with your needs:
This is the template file for generating certificates, i.e., the information stored here will be offered as default values during certificate generation. Locate and edit the following lines in accordance with your needs: <br>  
+
    <ul>
<pre>
+
      <pre>set KEY_COUNTRY=US
set KEY_COUNTRY=US
   
set KEY_PROVINCE=CA
 
set KEY_PROVINCE=CA
 
set KEY_CITY=SanFrancisco
 
set KEY_CITY=SanFrancisco
 
set KEY_ORG=OpenVPN
 
set KEY_ORG=OpenVPN
+
</pre>
+
    </ul>
</li>
+
  </li>
 
----
 
----
<li>
+
  <li>You can also set the size for the Diffie Hellman parameters:
You can also set the size for the Diffie Hellman parameters: <br>
+
    <ul>
<pre>
+
      <pre>set DH_KEY_SIZE=2048</pre>
set DH_KEY_SIZE=2048
+
    </ul>
</pre>
+
  </li>
</li>
   
----
 
----
<li>
+
  <li>Once you're done, save the file and close the editor</li>
Once you're done, save the file and close the editor
  −
</li>
   
----
 
----
<li>
+
  <li>Run the following commands:
Run the following commands: <br>
+
    <ul>
<pre>
+
      <pre>vars</pre>
vars
+
      <pre>clean-all</pre>
</pre>
+
    </ul>
<pre>
+
  </li>
clean-all
  −
</pre>
  −
</li>
   
----
 
----
<li>
+
  <li>Now we can start generating the certificates. Begin with the '''certificate authority''' ('''CA''') file:
Now we can start generating the certificates. Begin with the '''certificate authority''' ('''CA''') file: <br>
+
    <ul>
<pre>
+
      <pre>build-ca</pre>
build-ca
+
    </ul>
</pre>
   
'''NOTE''': you can press the "Enter" key when prompted to enter the values set in the ''vars.bat'' file earlier. Doing this will set the values to the default specified in ''vars.bat''. However, you should type in a meaningful '''Common Name'''.
 
'''NOTE''': you can press the "Enter" key when prompted to enter the values set in the ''vars.bat'' file earlier. Doing this will set the values to the default specified in ''vars.bat''. However, you should type in a meaningful '''Common Name'''.
</li>
+
  </li>
 
----
 
----
<li>
+
  <li>Next, build the '''server''' certificate and key:
Next, build the '''server''' certificate and key: <br>
+
    <ul>
<pre>
+
      <pre>build-key-server server</pre>
build-key-server server
  −
</pre>
   
'''NOTE''': once again, don't forget to specify a different Common Name (use the name "server" for easier management purposes). When prompted the sign and commit the certificate, type '''y''' and press "Enter".
 
'''NOTE''': once again, don't forget to specify a different Common Name (use the name "server" for easier management purposes). When prompted the sign and commit the certificate, type '''y''' and press "Enter".
</li>
+
    </ul>
 +
  </li>
 
----
 
----
<li>
+
  <li>Next, build certificates and keys for the '''clients''':
Next, build certificates and keys for the '''clients''': <br>
+
    <ul>
<pre>
+
      <pre>build-key Client1</pre>
build-key Client1
+
    </ul>
</pre>
   
'''TIP''': use the same Common Name as the certificate name (Client1 in this example). This will help you differentiate different clients easier. Pick meaningful names like "toms_PC", "company_maintenance", etc. Repeat this step as many times as you need, depending on the client quantity.
 
'''TIP''': use the same Common Name as the certificate name (Client1 in this example). This will help you differentiate different clients easier. Pick meaningful names like "toms_PC", "company_maintenance", etc. Repeat this step as many times as you need, depending on the client quantity.
</li>
+
  </li>
 
----
 
----
<li>Lastly, generate '''Diffie Hellman parameters''': <br>
+
  <li>Lastly, generate '''Diffie Hellman parameters''':
<pre>
+
    <ul>
build-dh
+
      <pre>build-dh</pre>
</pre>
+
    </ul>
</li>
+
  </li>
 
</ul>
 
</ul>
 +
 
==Step 3: OpenVPN server configuration==
 
==Step 3: OpenVPN server configuration==
    
*
 
*