Welcome to the IPFire Wiki

This wiki is a community-maintained resource about everything there is to know about IPFire. Join us and help us improving it!

Looking for something?

Use the search and find answers to everything about IPFire. If you cannot find what you are looking for, join our community and talk to fellow IPFire users, developers and everybody else involved in the project.

IPFire Community

Differences in Revisions: ios_v2

add more info...
#Configure iPad and iPhone for OpenVPN v2
## Preparations
* Install the iOS app [OpenVPN Connect](https://apps.apple.com/app/openvpn-connect/id590379981)
* [Configure](https://wiki.ipfire.org/configuration/services/openvpn/config) and create an OpenVPN client for your iPhone or iPad device.
* Make sure you document the **PKCS12 File Password:**. It will be needed in the next few steps.
There are a few different ways to create a unified file for use on an iOS device (iPhone or iPad device). It can be done manually by cutting and pasting information from various files. Or it can be done with one if the bash scripts below.
### Download Client Package
To get started go to the menu **Service** > **OpenVPN**, scroll to the **Connection Status and Control** section and click on the **Download Client Package (zip)** icon.
![](./connection_status_control_v2.png "Download Client Package (zip)")
##Single unified file (manual method)
Manual method: maybe for a separate web page.
There are 5 sections to a unified ovpn file:
1. Locate the OpenVPN client conf file
* The file is obtained from the [**Download Client Package (zip)**](/configuration/services/openvpn/ios_v2#download-client-package) above.
* Download and copy the `.ovpn` file to a new file
* For example: the new file will be named: `myPhone.ovpn`
* Add these lines to the end `myPhone.ovpn`:
key-direction bidirectional
2. Locate the **Root Certificate** / CA Directive
* Open the OpenVPN webpage (**Service** > **OpenVPN**), scroll down to the **Certificate Authorities and -Keys**
* Download the **Root Certificate** by clicking on the floppy disk. Locate the `cacert.pem` file in the Downloads folder.
* Copy the contents of `cacert.pem` to end of the `myPhone.ovpn`
* Add these lines to the end `myPhone.ovpn`:
3. Locate the Cert ? / Cert Directive
* .
* Add these lines to the end `myPhone.ovpn`:
4. Locate the private key
* .
4. Create an Encrypted Private Key
* The `myPhone.p12` file is obtained from the [**Download Client Package (zip)**](/configuration/services/openvpn/ios_v2#download-client-package) above.
* In the terminal, go to the directory where the `myPhone.p12` file is located and enter:
PKCS12_PW=<PKCS12 File Password> # mentioned above in Preparations.
openssl pkcs12 -nocerts -in iPhone.p12 -passin pass:$PKCS12_PW -passout pass:$PKCS12_PW
* Add these lines to the end `myPhone.ovpn`:
* Add these lines to the end `myPhone.ovpn`:
5. Locate TA key tls-auth
* The `ta.key` file is obtained from the [**Download Client Package (zip)**](/configuration/services/openvpn/ios_v2#download-client-package) above.
* Copy the contents of `ta.key` to end of the `myPhone.ovpn`
* Add this line to the end `myPhone.ovpn`:
Done creating the unified ovpn file! The `myPhone.ovpn` file should look similar to the file below.
![](./iphone_example.ovpn_v3.png "Example iphone.ovpn")
##Single unified file (scripted method)
* ovpn info?
* CA directive
* Cert directive
* Key directive
* tls-auth?
###IPFire side code
Installed on IPFire box
Copy the following to a directory on the IPFire box.
filename = `openvpncmd.sh`
set -e
#set -x
# OpenVPN script for IPCop/iOS, www.magnuswedberg.com
# Launch via:
# openvpncmd ovpn_file password(PKCS12 File Password)
# $1 param = YourNewOpenVPNfile.ovpn
# $2 param = PKCS12 Password
if (( $# < 2 )); then
# TODO: print usage
echo "Usage: openvpncmd ovpn_file password(PKCS12 File Password)"
exit 1
cp "$1" tmp.ovpn
PKCS12_PW="$2" # PKCS12 File Password
# Convert windows file to linux file (drop Carriage Returns)
sed -i 's/\r$//g' tmp.ovpn
# get key & value from input ovpn file
while IFS=" " read -r key value remainder
#echo "key=$key" ; echo "value=$value" ; echo "remainder=$remainder" ; echo
case "$key" in
verify-x509-name )
*pkcs12 )
done < tmp.ovpn
# Comment out the "tls-auth ta.key" line and the "pkcs12 *.p12" line
sed -i -E -e 's/^tls-auth /#tls-auth /' -e 's/^pkcs12 /#pkcs12 /' tmp.ovpn
fn=$(basename "$FILE")
cp tmp.ovpn $ovpnFile
rm tmp.ovpn
echo "key-direction bidirectional" >> $ovpnFile
echo "<ca>" >> $ovpnFile
cat /var/ipfire/ovpn/ca/cacert.pem | sed '/^-----BEGIN CERTIFICATE-----/,$!d' >> $ovpnFile
echo "</ca>" >> $ovpnFile
echo "<cert>" >> $ovpnFile
openssl pkcs12 -in $p12File -clcerts -nokeys -password pass:$PKCS12_PW | sed '/^-----BEGIN CERTIFICATE-----/,$!d' >> $ovpnFile
echo "</cert>" >> $ovpnFile
echo "<key>" >> $ovpnFile
openssl pkcs12 -nocerts -in $p12File -passin pass:$PKCS12_PW -passout pass:$PKCS12_PW | sed '/^-----BEGIN ENCRYPTED PRIVATE KEY-----/,$!d' >> $ovpnFile
echo "</key>" >> $ovpnFile
echo "<tls-auth>" >> $ovpnFile
cat /var/ipfire/ovpn/certs/ta.key | sed '/^-----BEGIN OpenVPN Static key V1-----/,$!d' >> $ovpnFile
echo "</tls-auth>" >> $ovpnFile
#echo "ovpn file = "
#cat $ovpnFile; echo
###Client side code
installed on your desktop or laptop
##Separate file for iOS keychain
[OpenVPN - How do I use a client certificate and private key from the iOS Keychain?](https://openvpn.net/faq/how-do-i-use-a-client-certificate-and-private-key-from-the-ios-keychain/)
1st file includes:
* ovpn info?
* CA directive
2nd file includes:
* Cert directive
* Key directive
* tls-auth?
* [OpenVPN - What Is A VPN?](https://openvpn.net/what-is-a-vpn/)
* [OpenVPN - FAQ regarding OpenVPN Connect iOS](https://openvpn.net/vpn-server-resources/faq-regarding-openvpn-connect-ios/)
* [Forensic Analysis of OpenVPN on iOS](https://www.farleyforensics.com/2019/06/07/forensic-analysis-of-openvpn-on-ios/)