ios - Can't able to install p12 file on iPhone -


i'm getting p12 file server. need install p12 file in device profiles, in settings app. below code

var documentsdirectory: nsurl? var fileurl: nsurl?  documentsdirectory = filemanager.default.urls(for: .documentdirectory, in: .userdomainmask).last! nsurl fileurl = documentsdirectory!.appendingpathcomponent("authrsa.p12")! nsurl  if (fileurl!.checkresourceisreachableandreturnerror(nil)) {      print("file exist") }else{      print("file doesn't exist")      {              try p12filedata.write(to: fileurl! url)         } catch {              print(error)         } } print(fileurl!) let p12data: nsdata = nsdata(contentsoffile: fileurl!.path!)! let key : nsstring = ksecimportexportpassphrase nsstring let options : nsdictionary = [key : "test"]  var rawitems : cfarray?  let securityerror: osstatus = secpkcs12import(p12data, options, &rawitems) print(securityerror)  let items = rawitems! as! array<dictionary<string, any>> let firstitem = items[0] let identity = firstitem[ksecimportitemidentity string] as! secidentity? let trust = firstitem[ksecimportitemtrust string] as! sectrust?  let ptr = p12data.bytes.assumingmemorybound(to: uint8.self)  let cfdata = cfdatacreate(kcfallocatordefault, ptr, p12data.length) let cert:seccertificate? = seccertificatecreatewithdata(kcfallocatordefault, cfdata!) print(cert!) let addquery: [string: any] = [ksecclass string: ksecclasscertificate, ksecvalueref string: certificate!, ksecattrlabel string: "my certificate"]          let status = secitemadd(addquery cfdictionary, nil) print(status) 

i'm getting crash "unexpectedly found nil value" @ line print(cert!), because certificate not able generating.

so can please me.

thanks in advance.


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -