macOS/iOS SecKeyChain

Ángel Rubén Valdeolmos Carmona 586 Reputation points
2022-05-12T11:08:50.787+00:00

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);
        }
    }
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,592 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.