首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NEVPNManager.saveToPreferencesWithCompletionHandler上的错误

NEVPNManager.saveToPreferencesWithCompletionHandler上的错误
EN

Stack Overflow用户
提问于 2016-01-15 17:57:15
回答 1查看 1.5K关注 0票数 5

我的目标平台是OSX10.10/ Xcode 7.2,我试图保存对NEVPNManager的首选项,我在domain=NEConfigurationErrorDomain中得到了一个错误:

代码语言:javascript
复制
Error Domain = NEConfigurationErrorDomain Code = 10 "permission denied" UserInfo = 0x610000073280 {NSLocalizedDescription = permission denied}

下面的示例代码:

代码语言:javascript
复制
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")
                    }
                }
            }
        })
    }
})

此外,我还找到了下一个日志条目:

代码语言:javascript
复制
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}

我有下一个权利

代码语言:javascript
复制
<?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>

下一次

代码语言:javascript
复制
<?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输出

代码语言:javascript
复制
<?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都有错误。

我做错什么了?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-02-29 12:42:47

我和苹果的支持者见了很久。他们说- NEVPNManager在10.10还没有完全可用。您应该升级到OS,或者使用OS的Strongswan前端(https://wiki.strongswan.org/projects/strongswan/wiki/MacOSX)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34817008

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档