ios - How do I configure identityData of NEVPNProtocolIKEv2 with String certificate? -


i using networkextension framework creating application, connect vpn server via nevpnprotocolikev2.

after research, found tutorial working networkextension framework, , try follow it. (http://ramezanpour.net/post/2014/08/03/configure-and-manage-vpn-connections-programmatically-in-ios-8/)

but, stuck when configure identitydata of protocol. here m code:

self.vpnmanager.loadfrompreferenceswithcompletionhandler { [unowned self] (error) in if error != nil {     printerror("\(error?.errordescription)")     return }  let p = nevpnprotocolikev2() p.username = server.username p.serveraddress = server.serverurl  // password persistent reference keychain self.createkeychainvalue(server.password, foridentifier: keychainid_password) p.passwordreference = self.searchkeychaincopymatching(keychainid_password)  p.authenticationmethod = nevpnikeauthenticationmethod.none self.createkeychainvalue(kvpnsecret, foridentifier: keychainid_psk) p.sharedsecretreference = self.searchkeychaincopymatching(keychainid_psk)   // certificate p.identitydata = ??????  p.useextendedauthentication = true p.disconnectonsleep = false  self.vpnmanager.`protocol` = p self.vpnmanager.localizeddescription = server.servername  self.vpnmanager.savetopreferenceswithcompletionhandler({ [unowned self] (error) in     if error != nil {         printerror("save config failed " + error!.localizeddescription)     }     }) 

}

in tutorial, p.identitydata nsdata, loading p12 file. have string call: server.certificate

this server.certificate has value this

"-----begin certificate-----\nmiieddcca1ygawibagibadanbgkqhki......1ietczg7salsbiaxpjzpzm5c6oifuckufzndpq==\n-----end certificate-----\n" 

this very long string, call x509certificate... or that, not remember exactly.


i found library support write string file p12, "openssl".

but demo code objective-c. keep trying port code swift, hard. (democode: ios: how create pkcs12 (p12) keystore private key , x509certificate in application programmatically?)


finally, have string certificate, , want configure p.identitydata application. how it?


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

mapreduce - Resource manager does not transit to active state from standby -

serialization - Convert Any type in scala to Array[Byte] and back -