我的目标平台是OSX10.10/ Xcode 7.2,我试图保存对NEVPNManager的首选项,我在domain=NEConfigurationErrorDomain中得到了一个错误:
Error Domain = NEConfigurationErrorDomain Code = 10 "permission denied" UserInfo = 0x610000073280 {NSLocalizedDescription = permission denied}下面的示例代码:
let manager = NEVPNManager.sharedManager()
manager.loadFromPreferencesWithCompletionHandler { (error) -> Void in
if((error) != nil) {
print("VPN load preferences error")
print(error!)
exit(0)
}
if manager.`protocol` == nil {
let proto = NEVPNProtocolIKEv2()
proto.serverAddress = "host.net"
proto.username = "username"
Keychain.save("vpnpassword", data: "password".dataUsingEncoding(NSUTF8StringEncoding)!)
proto.passwordReference = Keychain.load("vpnpassword") // I got the same error without passwordReference too
proto.authenticationMethod = NEVPNIKEAuthenticationMethod.None
manager.`protocol` = proto
manager.enabled = true
manager.localizedDescription = "VPN"
manager.saveToPreferencesWithCompletionHandler({ (error) -> Void in
if((error) != nil) {
print("VPN Save to Preferences error")
print(error!)
exit(0)
}
else {
do {
try manager.connection.startVPNTunnel()
print("Started error")
} catch {
print("Unexpected error")
}
}
}
})
}
})此外,我还找到了下一个日志条目:
Jan 10 14:24:51 y.local nehelper[196]: app has the com.apple.developer.networking.vpn.api entitlement but not the application-identifier entitlement
Jan 10 14:24:51 y.local nehelper[196]: app Failed to obtain authorization right for 3: no authorization provided
Jan 10 14:24:51 y.local app[33627]: __55-[NEVPNManager saveToPreferencesWithCompletionHandler:]_block_invoke142: failed to save the new configuration: Error Domain=NEConfigurationErrorDomain Code=10 "permission denied" UserInfo=0x608000660240 {NSLocalizedDescription=permission denied}我有下一个权利
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.application-identifier</key>
<string>T76ZSM474A.app</string>
<key>com.apple.developer.aps-environment</key>
<string>development</string>
<key>com.apple.developer.networking.vpn.api</key>
<array>
<string>allow-vpn</string>
</array>
<key>com.apple.developer.team-identifier</key>
<string>T76ZSM474A</string>
<key>com.apple.security.application-groups</key>
<array>
<string>T76ZSM474A.</string>
</array>
<key>keychain-access-groups</key>
<array>
<string>T76ZSM474A.group</string>
</array>
</dict>
</plist>下一次
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.application-identifier</key>
<string>T76ZSM474A.vpn</string>
<key>com.apple.developer.aps-environment</key>
<string>development</string>
<key>com.apple.developer.networking.vpn.api</key>
<array>
<string>allow-vpn</string>
</array>
<key>com.apple.developer.team-identifier</key>
<string>T76ZSM474A</string>
<key>com.apple.security.application-groups</key>
<array>
<string>T76ZSM474A.</string>
</array>
<key>keychain-access-groups</key>
<array>
<string>T76ZSM474A.group</string>
</array>
</dict>
</plist>embedded.provisionprofile拥有允许-vpn和正确的团队id (T76ZSM474A)。
构建的应用程序有下一个codesign输出
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.application-identifier</key>
<string>T76ZSM474A.app</string>
<key>com.apple.developer.aps-environment</key>
<string>development</string>
<key>com.apple.developer.networking.vpn.api</key>
<array>
<string>allow-vpn</string>
</array>
<key>com.apple.developer.team-identifier</key>
<string>T76ZSM474A</string>
<key>com.apple.security.application-groups</key>
<array>
<string>T76ZSM474A.</string>
</array>
<key>keychain-access-groups</key>
<array>
<string>T76ZSM474A.group</string>
</array>
</dict>
</plist>我试图对Network.framework进行反编译,但这并不容易。我在OSX10.11上检查了这个问题,但没有发现问题,我的应用程序工作正常。我将构建的应用程序从OSX10.11复制到OSX10.10,并得到了以前的错误。我认为文档有错误,OSX10.10中不支持的NEVPNManager或OSX10.10上的NEVPNManager都有错误。
我做错什么了?
发布于 2016-02-29 12:42:47
我和苹果的支持者见了很久。他们说- NEVPNManager在10.10还没有完全可用。您应该升级到OS,或者使用OS的Strongswan前端(https://wiki.strongswan.org/projects/strongswan/wiki/MacOSX)。
https://stackoverflow.com/questions/34817008
复制相似问题