Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

[Bug] Null Reference Exception Thrown in RegisterCache on Mac #147

Closed
jfullerton44 opened this issue Jul 22, 2021 · 5 comments
Closed

[Bug] Null Reference Exception Thrown in RegisterCache on Mac #147

jfullerton44 opened this issue Jul 22, 2021 · 5 comments
Labels
bug Something isn't working More-info-needed P2

Comments

@jfullerton44
Copy link

jfullerton44 commented Jul 22, 2021

image
When RegisterCache is run on mac a null reference is thrown in Msal.MacKeyChain.DeleteKey(String serviceName, String accountName). This issue does not appear on linux or windows at the moment.

Issue appears on Mac OS 11.4 (20F71)
Msal version 2.18.7

@jfullerton44 jfullerton44 changed the title [BUG] Null Reference Exception Thrown in RegisterCache on Mac [Bug] Null Reference Exception Thrown in RegisterCache on Mac Jul 22, 2021
@trwalke trwalke added bug Something isn't working P1 labels Jul 23, 2021
@trwalke
Copy link
Member

trwalke commented Jul 23, 2021

Adding P1 as this is throwing a null ref

@bgavrilMS
Copy link
Member

@jfullerton44 - looking at the stack trace above, I don't think you are using a recent version of the library.

Microsoft.Identity.Client.MSAL.Extensions is currently at version 2.18.8 and MSAL itself is at 4.35.

MsalCacheStorage.ClearCore was removed by this commit, exactly 2 years ago.

Can you please upgrade to latest versions of MSAL and cache ext and try again?

@jfullerton44
Copy link
Author

I updated MSAL to 4.35 and Extensions to 2.18.8 and this is the stack trace now
image

@jfullerton44
Copy link
Author

I seem to have found the issue. When the StorageCreationPropertiesBuilder was being created I needed to add the service and account name using

WithMacKeyChain(
    "msal_service",
     "msal_account");

After I added this the issue went away. This also explains why the issue was only appearing on mac

@bgavrilMS
Copy link
Member

bgavrilMS commented Jul 27, 2021

Yes, but please add something more descriptive than "msal_service" / "msal_account". Use the name of your app. Open KeyChain app on mac and see how the data is stored there and how these labels are used.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working More-info-needed P2
Projects
None yet
Development

No branches or pull requests

3 participants