4 Replies
      Latest reply: Jan 12, 2017 1:10 AM by eskimo RSS
      iOSerKi Level 1 Level 1 (0 points)

        I added a VPN-configfile into my project, and then how to install it?

        Only passing the Safari or E-mail ?  if YES, how to use the safari to install the file?

        The following code I written, but get error

        NSString *path = [[NSBundle mainBundle] pathForResource:@"vpnsetting" ofType:@"mobileconfig"];
        NSURL *fileURL = [NSURL fileURLWithPath:path];
        [[UIApplication sharedApplication] openURL:fileURL];
        

         

        error:

        nURL: failed for URL: "file:///var/containers/Bundle/Application/2FF7DA3F-662XXXXXX-004-ED329E846973/IKEv2_Demo.app/vpnsetting.mobileconfig" - error: "The operation couldn’t be completed. (zzzzOSStatus error -10814.)"
        
        • Re: How to install a .mobileconfig file programatically??
          iOSerKi Level 1 Level 1 (0 points)

          I add the "RoutingHTTPServer" library into my project to create a local server, like this:http://stackoverflow.com/questions/2338035/installing-a-configuration-profile-on-iphone-programmatically/9854934#9854934

          and then I got a error: Safari could not install a profile due to an unknown error.

           

          But I used the "Apple configurator 2" install it successful...  How to deal?

            • Re: How to install a .mobileconfig file programatically??
              eskimo Apple Staff Apple Staff (7,530 points)

              Let’s start with some basics: why are you setting up VPN this way?  Most developers do one of the following:

              • Are working in a managed environment, and thus the configuration profile gets installed via MDM

              • Are deploying via the App Store, and thus rely on Personal VPN (set up via the NEVPNManager API)

              It sounds like you’re ‘crossing the streams’ here, and there are good reasons to do that (for example, your VPN server requires you to use a VPN transport that’s not supported by Personal VPN) but I want to make sure that you have a good reason before continuing.

              Share and Enjoy

              Quinn “The Eskimo!”
              Apple Developer Relations, Developer Technical Support, Core OS/Hardware
              let myEmail = "eskimo" + "1" + "@apple.com"

                • Re: How to install a .mobileconfig file programatically??
                  iOSerKi Level 1 Level 1 (0 points)

                  en..I know, but now my problem is the VPN Server only support PPTP/L2TP, so the NEVPNManager can't work for it... 

                  Then I create a .mobileconfig and drag into my project instead of programing, but how to install it when the app running which I confused.

                  Through google, I found the way above, and try..   last, what's mean about MDM ??

                    • Re: How to install a .mobileconfig file programatically??
                      eskimo Apple Staff Apple Staff (7,530 points)

                      what's mean about MDM ??

                      That stands for mobile device management.  That’s a generic term but you can find information about this from an iOS perspective in the iOS Deployment Reference.

                      my problem is the VPN Server only support PPTP/L2TP, so the NEVPNManager can't work for it

                      Indeed.

                      btw You’re aware that we removed support for PPTP from iOS 10, right?  So you’re going to be restricted to L2TP.

                      Then I create a .mobileconfig and drag into my project instead of programing, but how to install it …

                      iOS does not have any API’s specifically designed to install configuration profiles.  However, you can kick off the installation process by opening a URL that points to a profile.  This will launch Safari with that URL, which will bounce the work to the profile ingestion subsystem.  Needless to say, this is a little indirect.

                      Most folks who do this host the profile on a web server.  Trying to host the profile within your app is un-fun because a) you need to implement your own web server, and b) there’s some nasty multitasking gotchas.

                      My recommendations:

                      • You should update your VPN server to support a more modern protocol.  That will allow you to use NEVPNManager, and all of these problems go away.

                      • If that’s not possible, put your profile on a web server rather than trying to serve it out of your app.

                      • If that’s not possible, you’re going to have to debug the interactions between your app’s built-in web server and the profile ingestion code.  You typically do that by:

                        1. Setting up a working case — That is, put your profile on a standard web server, point the profile ingestion code at that, and run a packet trace of its interactions when installing the profile.

                        2. Do the same for the non-working case

                        3. Compare the packet traces to see how the non-working case differs from the working case.

                        4. Correct any differences and repeat

                      For information on how to take a packet trace, see QA1176 Getting a Packet Trace.

                      Share and Enjoy

                      Quinn “The Eskimo!”
                      Apple Developer Relations, Developer Technical Support, Core OS/Hardware
                      let myEmail = "eskimo" + "1" + "@apple.com"