Xamarin iOS 为 KeyChain 添加价值,设备上的所有应用程序都可以访问它
Xamarin iOS add value to KeyChain which can be accessed by all apps on device
我为此创建了一个新问题,因为它与 Xamarin.当我偶然发现这个 question in Whosebug. It took me a while to figure out how to add anything into Keychain and them I stumbled upon this .
时,我正在寻找一种在 iOS 中唯一标识设备的方法
经过所有的磕磕绊绊,我想出了 this 一段代码来生成唯一令牌。
var s = new SecRecord(SecKind.GenericPassword)
{
AccessGroup = "kSecAttrAccessGroupToken",
ValueData = NSData.FromString(value),
Generic = NSData.FromString(key)
};
SecKeyChain.Add(s);
现在的问题是,即使我将此条目添加到钥匙串中,我也找不到它。我也很想知道我是否正确使用了 kSecAttrAccessGroupToken。
我的Enlistments.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>keychain-access-groups</key>
<array>
<string>my app id</string>
<string>kSecAttrAccessGroupToken</string>
</array>
</dict>
</plist>
kSecAttrAccessGroupToken
is writable only by CryptoTokenKit smart card drivers. Apps can query the keychain using that attribute in order to find items stored on a particular smart card. This attribute is not for any other use.
10.3.x 测试版中存在一个错误,允许任何应用程序也可以写入它,但已修复。
我为此创建了一个新问题,因为它与 Xamarin.当我偶然发现这个 question in Whosebug. It took me a while to figure out how to add anything into Keychain and them I stumbled upon this
经过所有的磕磕绊绊,我想出了 this 一段代码来生成唯一令牌。
var s = new SecRecord(SecKind.GenericPassword)
{
AccessGroup = "kSecAttrAccessGroupToken",
ValueData = NSData.FromString(value),
Generic = NSData.FromString(key)
};
SecKeyChain.Add(s);
现在的问题是,即使我将此条目添加到钥匙串中,我也找不到它。我也很想知道我是否正确使用了 kSecAttrAccessGroupToken。
我的Enlistments.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>keychain-access-groups</key>
<array>
<string>my app id</string>
<string>kSecAttrAccessGroupToken</string>
</array>
</dict>
</plist>
kSecAttrAccessGroupToken
is writable only by CryptoTokenKit smart card drivers. Apps can query the keychain using that attribute in order to find items stored on a particular smart card. This attribute is not for any other use.
10.3.x 测试版中存在一个错误,允许任何应用程序也可以写入它,但已修复。