SecKeyChain.Add return Security.SecStatusCode.MissingEntitlement

BhautikBhautik Member ✭✭✭

Hello,
SecKeyChain.Add always return Security.SecStatusCode.MissingEntitlement error.Below is my code.
`void StoreKeysInKeychain(string key, string value)
{

        var s = new SecRecord(SecKind.Identity)
        {
            ValueData = NSData.FromString(value),
            Generic = NSData.FromString(key)
        };
        var err = SecKeyChain.Add(s);
    }`

Anyone know how to resolved?

Tagged:

Answers

  • ObrockiObrocki Member ✭✭

    Does your Entitlements.plist have the Enable Keychain set?

    <dict>
        <key>keychain-access-groups</key>
        <array>
            <string>your bundle id</string>
        </array>
    </dict>
    
  • BhautikBhautik Member ✭✭✭

    @Obrocki said:
    Does your Entitlements.plist have the Enable Keychain set?

    <dict>
        <key>keychain-access-groups</key>
        <array>
            <string>your bundle id</string>
        </array>
    </dict>
    

    yes,It is there but still its not work.

  • LandLuLandLu Member, Xamarin Team Xamurai

    @Bhautik Try to check your project's iOS Bundle Signing: right click your project => iOS Bundle Signing.
    If you used simulators to test the keychain, the default setting for simulators of Custom Entitlements is null. You should set that to the Entitlement.plist in your project:

    After setting this you can test keychain on your simulators. Moreover generally we used SecKind.GenericPassword to store data.

Sign In or Register to comment.