Prerequisites
- A XCA PKI database https://youtu.be/ezzj3x207lQ
Create Required Certificates
- Launch XCA
- Open the PKI database if it is not already (File > Open DataBase), enter password
- Click on the Certificates tab, right click on your Intermediate CA certificate
- Select New
- On the Source tab, make sure Use this Certificate for signing is selected
- Verify your Intermediate CA certificate is selected from the drop down
- Click the Subject tab
- Complete the Distinguished Name section
internalName: OpenVPN Server
countryName: US
stateOrProvinceName: Virginia
localityName: Northern
organizationName: i12bretro
organizationUnitName: i12bretro Certificate Authority
commonName: vpn.i12bretro.local - Click the Generate a New Key button
- Enter a name and set the key size to at least 2048
- Click Create
- Click on the Extensions tab
- Set the Type dropdown to End Endity
- Check the box next to Subject Key Identifier
- Update the validity dates to fit your needs
- Click the Key Usage tab
- Under Key Usage select Digital Signature and Key Encipherment
- Under Extended Key Usage select TLS Web Server Authentication
- Click the Netscape tab
- Deselect all options and clear the Netscape Comment field
- Click OK to create the certificate
- Click on the Certificates tab, right click on your Intermediate CA certificate again
- Select New
- On the Source tab, make sure Use this Certificate for signing is selected
- Verify your Intermediate CA certificate is selected from the drop down
- Click the Subject tab
- Complete the Distinguished Name section
internalName: OpenVPN Client #1
countryName: US
stateOrProvinceName: Virginia
localityName: Northern
organizationName: i12bretro
organizationUnitName: i12bretro Certificate Authority
commonName: VPN Client 1 - Click the Generate a New Key button
- Enter a name and set the key size to at least 2048
- Click Create
- Click on the Extensions tab
- Set the Type dropdown to End Endity
- Check the box next to Subject Key Identifier
- Update the validity dates to fit your needs
- Click the Key Usage tab
- Under Key Usage select Digital Signature, Key Agreement
- Under Extended Key Usage select TLS Web Client Authentication
- Click the Netscape tab
- Deselect all options and clear the Netscape Comment field
- Click OK to create the certificate
- On the Certificates tab, click the OpenVPN Server certificate
- Select Extra > Generate DH Parameter
- Type 2048 for DH parameter bits
- Click OK
- Select a location for dh2048.pem and click Save
Exporting Required Files for OpenVPN
- In XCA, click on the Certificates tab
- Right click the Intermediate CA certificate > Export > File
- Set the file name with a .pem extension and verify the export format is PEM chain (*.pem)
- Click OK
- Right click the OpenVPN Server certificate > Export > File
- Set the file name with a .crt extension and verify the export format is PEM (*.crt)
- Click OK
- Right click the OpenVPN Client #1 certificate > Export > File
- Set the file name with a .crt extension and verify the export format is PEM (*.crt)
- Click OK
- Click on the Private Keys tab
- Right click the OpenVPN Server key > Export > File
- Set the file name with a .pk8 extension and verify the export format is PKCS #8 (*.pk8)
- Click OK
- Right click the OpenVPN Client #1 key> Export > File
- Set the file name with a .pk8 extension and verify the export format is PKCS #8 (*.pk8)
- Click OK
Setting Up OpenVPN Server in OpenWRT
- Open a web browser and navigate to your OpenWRT IP address
- Login when prompted
- Select System > Software from the navigation menu
- Click on the Update lists button to update the software repositories
- Click the Dismiss button once the update has completed
- Type openvpn in the filter field
- Click the Install... button next to openvpn-openssl
- Click the Install button to confirm installing with dependencies
- Click the Dismiss button once the install has completed
- Click the Install... button next to luci-app-openvpn
- Click the Install button to confirm installing with dependencies
- Click the Dismiss button once the install has completed
- Refresh the browser window
- Select VPN > OpenVPN from the navigation menu
- Under the Template based configuration heading, enter OpenVPNServer as the Instance name and select Server configuration for a routed multi-client VPN as the template > Click Add
- Click the Edit button across from the newly created OpenVPNServer entry
- Next to ca, click the button, browse to and upload the previously exported CA .pem file
- Select the ca .pem file to be used
- Next to dh, click the button, browse to and upload the previously exported dh2048.pem file
- Select the dh2048.pem file to be used
- Next to cert, click the button, browse to and upload the previously exported OpenVPN server .crt file
- Select the .crt file to be used
- Next to key, click the button, browse to and upload the previously exported OpenVPN server .pk8 file
- Select the ca .pk8 file to be used
- Click the Additional Field dropdown > Select proto > Click Add
- Set the value of proto to udp
- Click the Additional Field dropdown > Select port > Click Add
- Set the value of port to 1194
- Click the Additional Field dropdown > Select dev_type > Click Add
- Set the value of dev_type to tun
- Scroll to the bottom of the page and click the Save & Apply button
- Select VPN > OpenVPN from the navigation menu
- Check the Enabled checkbox next to the OpenVPNServer entry and click the Save & Apply button
- After a few seconds the page will refresh and the OpenVPN server should be running
NOTE: If the server is not running, check the system logs for troubleshooting by selecting Status > System Log from the navigation menu
Installing OpenVPN Client Software and Testing
- Download the OpenVPN software Download
- Run the installer with all the default values
- Click the Start button and search OpenVPN GUI
- Select OpenVPN GUI from the results to start the application
Creating the OpenVPN Client Profile
- Download the OVPN template Download
- Rename the .ovpn template something meaningful
- Edit the .ovpn template replacing the following:
<#replace with dynamic dns#> with a dynamic DNS or external IP address to your server
<#replace with CA chain#> with the contents of CA_Chain.pem
<#replace with client 1 cert #> with the contents of OpenVPN_Client #1.crt
<#replace with client 1 key #> with the contents of OpenVPN_Client #1.pk8 - Save your changes
- Copy the .ovpn template to OpenVPN install directory/config
- Right click OpenVPN GUI in the system tray > Connect