Skip to content

SecureStorage in iOS simulator #21195

@ricardommatias

Description

@ricardommatias

Description

Calling SecureStorage.Default.SetAsync(key, value) when debugging on an iOS simulator throws an exception:

System.Exception: Error adding record: MissingEntitlement
   at Microsoft.Maui.Storage.KeyChain.SetValueForKey(String value, String key, String service)
   at Microsoft.Maui.Storage.SecureStorageImplementation.SetAsync(String key, String value, SecAccessible accessible)
   at Microsoft.Maui.Storage.SecureStorageImplementation.PlatformSetAsync(String key, String data)
   at Microsoft.Maui.Storage.SecureStorageImplementation.SetAsync(String key, String value)

I tried setting the CustomEntitlements in the .csproj but still it doesn't work:

<CodesignEntitlements>Platforms\iOS\Entitlements.plist</CodesignEntitlements>

Entitlements.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>
</dict>
</plist>

I also tried to add the Keychain Sharing key to the Entitlements.plist but still the same exception is thrown:

<key>keychain-access-groups</key>

Steps to Reproduce

Call SecureStorage.Default.SetAsync(key, value) when debugging in an iOS simulator.

Expected outcome: No exception thrown

Link to public reproduction project repository

No response

Version with bug

8.0.7 SR2

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 17.2

Did you find any workaround?

No response

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-essentialsEssentials: Device, Display, Connectivity, Secure Storage, Sensors, App Infoplatform/iost/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions