flutter_secure_storage icon indicating copy to clipboard operation
flutter_secure_storage copied to clipboard

[macOS] Read always return null with signed and notarized app

Open jdk-21 opened this issue 1 year ago • 9 comments

I encountered an issue on Mac with this package. When I debug my app, I can read from secure storage just fine, even in flutter release mode. But after building, singing and notarizing the app secure storage stops working and only returns null, when you try to read from it. The app has hardened runtime enabled. I already tried adding the entitlements in debug and release:

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

Before I noticed this issue, I had the entitlement configured like this:

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

Is it possible that the keychain already exists on the development Mac but the notarized app hasn't access? Is there a way to delete all data added by the secure storage package, to check this hypothesis? Has someone encountered a similar issue?

I'm using version 9.0.0

jdk-21 avatar Mar 02 '24 13:03 jdk-21

Hi @jdk-21,

Very interesting and good to know there are even more issues with macOS. I am curious though, how on earth did you get it this package to work at all on macOS?

Even just in debug mode with self signed dev builds? I cannot get it to read the data when app starts. If keep running same app, reset all reads and then try to read, the securely stored data is there and read nicely, but if I build it again or even just hot-restart the app, the data previously stored is not there. Like starting from an empty file every time.

Link with more info https://github.com/mogol/flutter_secure_storage/issues/532#issuecomment-1987279333

Any insights you might have on getting it to work at all with macOS would be welcome 😄


EDIT: Got it working now! (The link above has the details)

rydmike avatar Mar 10 '24 16:03 rydmike

Ok, great. I basically followed the instructions in the Readme. Does it work for you with Hardened Runtime enabled after Notarization?

jdk-21 avatar Mar 10 '24 21:03 jdk-21

@jdk-21 did you manage to make it working?

AndreiMisiukevich avatar May 10 '24 23:05 AndreiMisiukevich

I couldn't get it to work yet.

jdk-21 avatar May 11 '24 07:05 jdk-21

@jdk-21 it could be related to keychain accessibility.

What sort of restrictiveness have you set up in production?

You might want to check if it works with v9.2.2, now that #718 and #719 have been merged.

techouse avatar May 21 '24 10:05 techouse

Hi I had the same issue after upgrading to flutter 3.19.6 the app would work fine in debug/release, but as soon as I signed it for notorization the app would stop working.

After upgrading to v9.2.2 and adding this to my Release.entitlements it seems to work again.

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

werner-scholtz avatar May 22 '24 14:05 werner-scholtz

After upgrading to v9.2.2 and adding this to my Release.entitlements it seems to work again.

Cool 😎

techouse avatar May 22 '24 14:05 techouse

@techouse I updated to 9.2.2 and tried the example app. In debug everything works fine like before, but after signing and notarizing the app stops working again.

jdk-21 avatar Jun 03 '24 15:06 jdk-21

Maybe check what the output of codesign -d --entitlements - YourApp.app is before and after signing the .app

werner-scholtz avatar Jun 04 '24 05:06 werner-scholtz

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Aug 13 '24 19:08 github-actions[bot]

I am closing all older issues. If this issue still exists in the latest version, please let me know.

juliansteenbakker avatar Aug 13 '24 20:08 juliansteenbakker

It still exists, I can't figure it out. Did anyone found a solution?

esuljic avatar Feb 05 '25 12:02 esuljic

Which version have you tried? Does it also exist with the latest beta version?

juliansteenbakker avatar Feb 05 '25 12:02 juliansteenbakker

https://github.com/juliansteenbakker/flutter_secure_storage/issues/804#issuecomment-2636820309 Here is my report, I figured out it is a different issue so I wrote there instead.

esuljic avatar Feb 05 '25 13:02 esuljic

Same error PlatformException(Unexpected security result code, Code: -34018, Message: A required entitlement isn't present., -34018, null)

shanelau avatar Feb 11 '25 06:02 shanelau