Perform MTLS connection with another device

Hello there!

In our team we are looking for a way to connect to an external device to get and send live information through it. We need to do this because our app is required to work on offline environments and we can't expect to have Internet connection.

The device that we connect against is a PC that may not have Internet connection as well.

Because of that, we decided to implement live updates via WiFi:

  • The PC generates a WiFi access point.
  • The PC launches an internal server in a local IP of that local network.
  • The phone connects to the access point and queries the PC through the server's local IP.

Also we wanted to have security for this interaction. So we agreed on doing MTLS on the connection step, so we can both verify that the server is talking to the phone and viceversa. We do this storing p12 on both phone and PC and verifying their identities via certificates that contain those ids.

In our phone configuration, we use the NEHotspotConfigurationManager to connect to the PC's network. Then we make sure that we are connected to the WiFi network using NEHotspotNetwork.fetchCurrent.

After that, we are using URLSession to connect to the PC's server with the local IP. We are using the SessionDelegate and implement the didReceiveChallenge method. We do it in a very similar way to the one found in this other DevForum thread.

Do you think we are following the right approach to this problem? Do you see any potential gaps in this implementation?

I have a couple of posts I think you should read first:

Please read these through and then come back with any follow-up questions.

Share and Enjoy

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

Perform MTLS connection with another device
 
 
Q