Personal VPN with self-signed certificate on a server side

Goodday, everyone!

I want to make iOS VPN app based on NEVPNManager. I tried to use auth by certificate and passed identityData and identityDataPassword into my protocol config to use it. If I install CA manually into my system - the config and connection work fine and stable. If I tried to use this app without manual installation - I got Certificate evaluation error = kSecTrustResultRecoverableTrustFailure error.

I tried to install my certificate like SecItem into Anchor Certificates, but it is still not visible on settings and could be used to verify my self-signed cert from server.

How work with it correctly? Could I use a self-signed certificate on the server-side and install it programmatically on iPhones to verify it on client-side? How make it correctly? Please give me some advice about it! Thank you!

Answered by DTS Engineer in 725215022

If you create a packet tunnel provider then you’re in charge of how your communicate with the VPN server. You can customise server trust evaluation as you see fit, or implement a protocol that doesn’t use certificates for server trust evaluation, or doesn’t do trust evaluation at all.

Having said that, this is not an easy task. You need to implement the entire VPN protocol yourself. So, whereas with Personal VPN you get to use Apple’s IKEv2 protocol implementation, with a packet tunnel provider you have to implement the IKEv2 protocol yourself. That’s not easy, and it’s a lot less easy then getting a trusted certificate for your server [1].

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] I’m not a VPN configuration expert but my understanding is that Let’s Encrypt certificates work for this.

How work with it correctly?

Personal VPN has no support for customising server trust evaluation. The server certificate returned by the VPN server must be trusted by the system.

The best way to test for Personal VPN compatibility is to create a configuration profile for your VPN. If you are able to create a working configuration profile using just the com.apple.vpn.managed payload (and com.apple.security.pkcs12, if you need to supply a client identity) you should be good to go for Personal VPN. If you have to include a com.apple.security.root payload, you have work to do on the VPN server side.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

It will work fine if I install the certificate or config manually, but I want to do this programmatically. Could I install certificates from the app? Or maybe I could use another verification type? How build the VPN app with a self-signed certificate on the server side? Which instruments I need to use?

Could I install certificates from the app?

No.

Or maybe I could use another verification type?

No. Personal VPN supports IPsec and IKEv2, both of which rely on server trust evaluation.

How build the VPN app with a self-signed certificate on the server side?

You don’t. This is what I meant by “The server certificate returned by the VPN server must be trusted by the system.” [Sorry about the typo.]

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Okay. Is it will be possible if I will use NETunnelProviderManager?

Accepted Answer

If you create a packet tunnel provider then you’re in charge of how your communicate with the VPN server. You can customise server trust evaluation as you see fit, or implement a protocol that doesn’t use certificates for server trust evaluation, or doesn’t do trust evaluation at all.

Having said that, this is not an easy task. You need to implement the entire VPN protocol yourself. So, whereas with Personal VPN you get to use Apple’s IKEv2 protocol implementation, with a packet tunnel provider you have to implement the IKEv2 protocol yourself. That’s not easy, and it’s a lot less easy then getting a trusted certificate for your server [1].

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] I’m not a VPN configuration expert but my understanding is that Let’s Encrypt certificates work for this.

Okay. I understood that. Thanks for your replies!

Personal VPN with self-signed certificate on a server side
 
 
Q