简体   繁体   English

macOS 催化剂上钥匙串项的 PersistentRef

[英]PersistentRef of keychain item on macOS catalyst

Background背景

I'm trying to build an app that connects to VPN using native IKEv2 implementation.我正在尝试构建一个使用本机 IKEv2 实现连接到 VPN 的应用程序。 The app should be built for iOS but run on macOS as well by using Catalyst platform.该应用程序应为 iOS 构建,但也应使用 Catalyst 平台在 macOS 上运行。

Situation情况

When connecting to VPN using native IKEv2 implementation in iOS/macOS - to use username and password authentication, app has to pass a persistent keychain reference to a keychain item containing the password.在 iOS/macOS 中使用本机 IKEv2 实现连接到 VPN 时 - 要使用用户名和密码身份验证,应用程序必须将持久的钥匙串引用传递给包含密码的钥匙串项目。 ( Reference ) 参考

Problem问题

On iOS it works perfectly, but when initiating VPN connection on Catalyst platform, VPN service cannot retrieve the password using given persistent reference.在 iOS 上它工作得很好,但是在 Catalyst 平台上启动 VPN 连接时,VPN 服务无法使用给定的持久引用检索密码。 Console prints:控制台打印:

[] (null): Failed to copy content, SecKeychainItemCopyContent returned The contents of this item cannot be retrieved.

The keychain item is stored in the keychain, persistent reference is not nil , but for some reason, OS's VPN service couldn't retrieve the password.钥匙串项存储在钥匙串中,持久引用不是nil ,但由于某种原因,操作系统的 VPN 服务无法检索密码。

If I try to retrieve the password using that same persistent reference - everything works as expected and the password is retrieved.如果我尝试使用相同的持久引用检索密码 - 一切都按预期工作,并检索密码。

let query: [String: Any] = [
    kSecClass as String: kSecClassGenericPassword,
    kSecAttrPersistentReference as String: persistentRef,
    kSecReturnData as String: true
]
        
var item: CFTypeRef?
let status = SecItemCopyMatching(query as CFDictionary, &item)

Any information will be highly appreciated.任何信息将不胜感激。 Maybe some flags should be added when saving password to keychain?也许在将密码保存到钥匙串时应该添加一些标志? Maybe some flags should be added when retrieving the persistent reference from keychain specifically on Catalyst platform?在专门在 Catalyst 平台上从钥匙串检索持久引用时,也许应该添加一些标志?

I asked this question directly through Apple's feedback support, the answer I was given is:我直接通过苹果的反馈支持问了这个问题,得到的答案是:

苹果支持

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM