open .p12 file

Hi,


I have this requirement to download .p12 file(certificate) from a vendor and make it available on my app for the user to install it on to his device.

Now If I attach a .p12 file to yahoo email and when the recipient clicks on the file it will start installing I am just trying to get the same behaviour.

As of now in my app I am able to download the p12 file and store it in the apps documents directory.


func saveCert(serialId : String){

let source = "https://myhost.com/serialId"

let url = NSURL(string: source)

let request = NSURLRequest(URL: url!)

let config = NSURLSessionConfiguration.defaultSessionConfiguration()

let session = NSURLSession(configuration: config)

let task = session.dataTaskWithRequest(request, completionHandler: {(data, response, error) in

if (error == nil) {

let statusCode = (response as! NSHTTPURLResponse).statusCode

print("Success: \(statusCode)")

let filename = self.getDocumentsDirectory().stringByAppendingPathComponent("test.p12")

print(filename)

data?.writeToFile(filename, atomically: true)

let filemgr = NSFileManager.defaultManager()

if filemgr.fileExistsAtPath(filename) {

print("File exists")

} else {

print("File not found")

}

}

else {

print("Faulure: %@", error!.localizedDescription);

}

});

task.resume()

}

Now i need to open this file so user will be taken to install profile screens. Please help.


Thanks,

Amar.

open .p12 file
 
 
Q