question

Angelru-4290 avatar image
0 Votes"
Angelru-4290 asked Angelru-4290 commented

macOS/iOS SecKeyChain

I'm trying to access the keychain to get the installed certificates, but it always returns null, I don't see the option to enable KeyChain Info.plist, I don't see the entitlements.plist file in net maui.

I installed the pfx certificate on my macOS, but in the code output it says "item not found".

a custom provisioning profile is needed?


    SecRecord rec = new(SecKind.Certificate);
     SecStatusCode code;
     SecKeyChain.QueryAsRecord(rec, out code);
     NSData[] nsDatas = SecKeyChain.QueryAsData(rec, false, 999, out code);

     if (nsDatas != null)
     {
         foreach (NSData item in nsDatas)
         {

             X509Certificate2 cert = new X509Certificate2(item.ToArray());
             x509Certificate2s.Add(cert);
         }
     }

dotnet-maui
· 9
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Removed the dotnet-xamarin tag since your question is about MAUI

0 Votes 0 ·

Hi @Angelru-4290, I found you have asked this question at https://github.com/dotnet/maui/discussions/6879, you could follow the progress.

0 Votes 0 ·

This same code with a non-maui application retrieves the certificates installed on my mac, but in maui the SecStatusCode is ItemNotFound, am I missing something? i'm stuck at work right now.

can someone tell me why?

0 Votes 0 ·

Hi @Angelru-4290, Mac Catalyst apps only have access to the data protection keychain, you could check the updates here : https://github.com/dotnet/maui/issues/7126#issuecomment-1126147716

0 Votes 0 ·
Show more comments

0 Answers