Way to install mdm certificates programmatically in app - ios

this may sound a bit dodge, but im working on a parental app/browser lockdown app, and the use of the mdm service is basically the functionality i need, but i want the users to be able to control the mdm services for their childs device through a website.
I have everything working, except at the moment im not sure if there is a way to actually install the certificates needed programmatically in my app. I can do it manually through safari, but that detracts from the apps experience.
I basically want to mimic the functionality safari gives when downloading these certs but in my app.
has anyone tried something like this before?
alternatively, is there a way to get a UIWebView to respond to the mime-type of application/x-x509-ca-cert and application/x-apple-aspen-config ?

My knowledge of this could be outdated because I tried this on iOS 5.X. So, be aware.
At that moment, you weren't allowed to install certificates from your application (so UIWebView with application/x-x509-ca-cert didn't work). I believe an app should have special entitlement (which only system apps can have) to install a certificate to iOS' trusted certs store.
I believe the same is true for configuration profile installation via UIWebView.
By the way, here is an old discussion about it: https://groups.google.com/forum/#!topic/iphonesdkdevelopment/8QDPE1juB2g
However, I think you should try it now. Things could have changed.
Now, regarding installation of configuration profiles through Safari. I am not sure whether you are doing this completely manual or semi-manual, but just in case if you are doing this completely manual, here is the code which will allow you to partially automate it.
NSURL* url = [NSURL URLWithString: #"<URLOfPageWhichHasConfigProfile>"];
[[UIApplication sharedApplication openURL: url];
This will switch to Safari, which will switch to Preferences after that and after user approval it will get back to Safari. I know, it's not perfect.

Related

iOS, config files and sandboxing

My understanding is that because of sandboxing, it isn't possible to view any text file (ie config file) associated with an iOS app using another app. Something quite simple with Android. Am I mistaken?
I am trying to implement a text config file with a Unity iOS app that gets loaded and parsed once when the application boots.
This config file would also be able to be edited and saved manually on that actual iOS device.
(addendum)
In Unity there is PersistentDataPath which resolves to /var/mobile/Container/Data/Application/foo/Documents
Is there an iOS supported file explorer app that will allow me view and edit files in this location (without jailbreaking)?
Use can check iOS App Groups. It allows multiple apps access to shared containers and allow interprocess communication. There is no so much documentation about this, but maybe that's what you're looking for. At least you can share NSUserDefaults between the apps.
NSUserDefaults it's a most simple way to save any (not big) configurations for your app. For manual editing: if your app on the device signed with developer certificate, you can connect through any iOS supported file explorer app and edit it. But after release, from App Store, your app installed in restricted/private path, so it's not possible, if only you don't have a jailbreak.
Initial configuration you can put into your app bundle, and at the first run just copy them to NSUserDefaults.
Short answer: There are utilities such as iExplorer - https://macroplant.com - that allow "file manager" type access. However...
Long answer: If your app requires users to buy (or get) other software to modify configuration files, the chances of Apple approving it are slim to none.
The appropriate thing to do is to provide a User Interface in your own app which allows the user to modify / update the settings.

Install MDM profile via SafariViewController

I was wondering is there a way to install the profile(.mobileconfig) via SafariViewController. I'm aware that only Mail.app and Safari.app have the privileges of doing so.
So, if there is way that SafariViewController can handle such request, please let me know.
Thanks,
Yathish
It looks like it's possible to install mobile configuration profiles (.mobileconfig) via SFSafariViewController since iOS 11.3. I confirmed this on both iOS 11.3 and iOS 12 beta.
See here for more details: https://forums.developer.apple.com/thread/103337
As the documents written for SafariViewController(https://developer.apple.com/library/prerelease/ios/documentation/SafariServices/Reference/SFSafariViewController_Ref/index.html), are saying that the SafariViewController is minimizing the work of developers who need to create UIWebView inside the application which need to show the web interface in application.
On the other side Safari.app is a different iceland where things are going on, and our application is a different one. Apple granted different level of permissions to applications. Based on that the Mail.app and the Safari.app are enabled to install the .mobileconfig(configuration files).
As we Apple is very much clear about the functionality of the SafariViewController, they will not allow us to install the .mobileconfig file from out applications with SafariViewController.

Is there a way to get the search result i get in the App Store app on the iOS device? ( How to get the ipa file of "App Store"? )

Updated on 2015-11-1:
One solution I am trying is to start App Store using Applium, so that I can record/monitor iOS UI elements. just like what we did Selenium.
Let's treat App Store as a standard iOS app, is it possible to:
uninstall App Store from my iphone.
get the ipa file of App Store
unzip the ipa file and get the app bundle
run Appium with App Store's app file
Is it possible to get App Store 's ipa file?
======
I want to know the position of my apps when I search on the App Store. When I use the iTunes Search API. I notice the result returned from the iTunes search API for a specific search term are different from the result on the iOS App Store app.
I found This Question is also about this, the owner of that has find out the reason about this condition.
But there is no answer to solve this problem.
Actually I've been trying to build the search request, but it cames that the iOS Appstore is using the HTTPs request, so I don't know what to do with this.
Hope someone can help, I'll be very appreciate.
There is at this time no way to specify that you want the results you would get from an iOS device.
The most obvious solution that comes to mind is to build a search request that appears as I it came from ios in your app code.
I'm sure its possible to determine that by basically proxying an actual iPhone using say your router on your home network to log the traffic from an iphone.
Once you have that you can then basically reverse engineer the call in your app code.
As you can refer from Apple's guidance: Search API, there are too many ways of parameter combination.(Parameters includes:term, country, media, entity, attribute, callback, limit, lang, version, explicit, etc.) So it's almost impossible to find out the way of combination that App Store is adapting so as to get the same search results as users get directly from App Store.
You might want to see if you can get this to work:
In Mac OS X:
Launch iTunes
Under Library menu, click on [Apps] menu.
The iTunes will display all installed app
Right-click on one of those apps
Then click “Show in Finder” option
An alternative to this is simply open the directory of .ipa files stored by using this path: User/Music/iTunes/Mobile Applications
This probably only works with apps you downloaded, but it is worth trying.
It's possible to listen in on https connections by installing a trusted ssl certificate on the device and running traffic through a proxy - basically performing a man-in-the-middle attack on yourself. I've previously used Charles Proxy to do this - here's the guide how to set this up. That way you should be able to see exactly what request the App Store app is sending and what response it is getting. And thus it should also be possible to spoof this request and parse the results elsewhere.

iOS - serving configuration profile via UIWebView

My question is: would it be at all possible to avoid the call to Safari so as to install the profile?
I am able to use the localhost server approach described in Installing a configuration profile on iPhone - programmatically to serve it through Safari, but would like to avoid having to call it and then have to re-open the app on confirmation...
I know Safari and Mail are supposed to be the only applications whose permissions allow them to launch those profiles, but since the Mime type is now public ("application/x-apple-aspen-config"), would there be a way to make it work with a UIWebView?
I found several resources talking about this (mostly saying it isn't possible) but most are over 3-4 years old, which makes me wonder if anything might have changed in the meantime, or if Safari and Mail remain as the only web-based "methods" to launching configuration files.
Apparently not possible yet (15/09/15).
Hopefully this will change in the future...

iOS: Possible to install configuration profiles on device without going through safari?

I'm trying to install a .mobileconfig file through an application without going through the Safari or Mail apps.
At the moment, I can download the file in my application, but still have to pass it to safari to handle. This means that the user gets dumped back in safari after they've installed the profile, whereas I want to return them to my application.
The docs mention that Safari looks for the .mobileconfig extension, which it presumably passes on to the Settings app. Is there a way to cut out the middleman, like a prefs:... URL scheme?
I've searched for a while and tried everything I can think of - no luck so far. It looks like you have to go through Safari to do it.
To improve user experience, you can launch Safari with a page that you host that 1) allows the user to install the configuration profile and 2) allows them to come back to your app via a custom url scheme (yourapp://app/check_profile).
I posted an answer with code which does what akhomenko mentioned, but automatically (no user interaction required), here: Installing a configuration profile on iPhone - programmatically

Resources