5

我的目标平台是 OS X 10.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>

下一个 xcent

<?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)

构建的应用程序具有下一个协同设计输出

<?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,但这并不容易。我在 OS X 10.11 上检查了这个问题,但没有发现问题,我的应用程序运行正常。我将构建的应用程序从 OS X 10.11 复制到 OS X 10.10,我得到了以前的错误。我认为文档有错误,OS X 10.10 不支持 NEVPNManager 或 OS X 10.10 上的 NEVPNManager 有错误。

我做错了什么?

4

1 回答 1

0

我很早就与 Apple 支持人员会面了。他们告诉我们——NEVPNManager 在 10.10 上并不完全可用。您应该升级到 OS X El Capitan 或使用 Strongswan Frontend for OS X ( https://wiki.strongswan.org/projects/strongswan/wiki/MacOSX )。

于 2016-02-29T12:42:47.283 回答