Hi again,
I found some posts on the internet on which they say that apple disabled "VPN on demand" on newer versions of iOS or newley shiped devices.
I found out that there is an iPhone Configuration Utility (IPCU) which can be directly downloaded on the apple webpage which allows the to create and set profiles on an iPhone.
Setting such a profile works but I had problems to get "Custom SSL with VPN on demand" to get working with my pfsense OpenVPN server. The intention is that I setup the domains from my intranet as the e-mail server and when the e-mail app tries to connect to this URL the VPN connection will start. Instead of using "Push Mail" I would try to use automatic check by the mail app every 15min - hopefully the vPN will start when "VPN on demand" is configured correctly.
Perhaps someone can help me to configure this with the help of the following tutorial:
http://simonguest.com/2013/03/22/on-demand-vpn-using-openvpn-for-ios/
This is my iOS inline config from the pfsense export utility:
persist-tun
persist-key
cipher AES-256-CBC
tls-client
client
remote xx.yy.xx.yy 443 tcp
comp-lzo
nobind
keepalive 5 30
<ca>-----BEGIN CERTIFICATE-----
.....
-----END CERTIFICATE-----
<key>-----BEGIN RSA PRIVATE KEY-----
.....
-----END RSA PRIVATE KEY-----</key>
<tls-auth>#
# 2048 bit OpenVPN static key
#
-----BEGIN OpenVPN Static key V1-----
....
-----END OpenVPN Static key V1-----</tls-auth>
key-direction 1</ca>
Thank you for your help!
–-- edit ----
I got it. My iPhone starts the OpenVPN connection to my pfsense OpenVPN server. The config I posted above is the one the OpenVPN Export utlity created. Follow the instructions on the URL I posted above - they are correct. I just had to modify some parameters on the config to get it working (Custom options with "key" and "Value":
Export the CA.crt to your computer and replace every newline with \n to make it one line. (As described on the URL above)
You need a password protected .p12 of the client certificate which contains .key and .crt. pfsense itself cannot do that from GUI. I exported the .crt and .key to pfsense /tmp. Then I ran the command on the webpage ( openssl pkcs12 -export -in client1.crt -inkey client1.key -out client1.p12 ) and set a password. I imported that new password protected .p12 into the IPCU.
On the .ovpn config I exported from pfsense there is a part "tls-auth". I created this key in the custom options of IPCU and as value I did the same as for the "ca". everything in one line and every newline as \n
ca –---BEGIN CERTIFICATE-----\nABCDEF112312.........\n-----END CERTIFICATE-----
tls-auth –---BEGIN OpenVPN Static key V1-----\nABCDEF112312.........\n-----END OpenVPN Static key V1-----
comp-lzo value
persist-tun value
persist-key value
cipher AES-256-CBC
tls-client value
client value
key-direction 1
Push-Mail seems not to work with OpenVPN - probably because the VPN connection is in standby and will only be established if the iPhone app starts to check the E-Mails every 15min and so is using "VPN on demand".
Will do some more tests with bigger delays to make sure iPhone awakes froms sleep with VPN and hopefully same will happen when disconnection the iphone from the USB data cable which I still have connected to view what is happening on my iphone in the IPCU cosole.