How to enable keychain sharing with Siri kit exten

2019-08-19 18:21发布

问题:

I want to enable keychain sharing between my app and sirikit extension. I have added keychain access group with same string for app and sirikit. Also added App group for both the targets with same string. I am using Locksmith as a keychain wrapper, which is also using the kSecAttrAccessGroup property with the value teamID + keychain access group ID. But I am getting the following error when I try to run from siri extension:

CredStore - performQuery - Error copying matching creds.  Error=-25300, query={class = inet;
        "m_Limit" = "m_LimitAll";
        ptcl = htps;
        "r_Attributes" = 1;
        srvr = "appurl.com";
        sync = syna;
    }

Any guidance is appreciated. Thank you

回答1:

The reason it was not working because the TeamID or AppIdentifierPrefix was different in the provisioning profile the app and the siri extension was using. When we us the keychain access group, if you check the entitlements the keychain access group is prefixed with AppIdentifierPrefix which is the TeamID or AppID that is attached with your account:

<key>keychain-access-groups</key>
<array>
    <string>$(AppIdentifierPrefix)common_keychain_access_group_string</string>
</array>

And this AppIdentifierPrefix must be same for both the app and sirikit. Thank you