How I may call Keychail APIs using .Net Core on MacOs. Any help please.
I have looked into the following issues, but did not getting it. Thanks
https://github.com/dotnet/corefx/pull/16588
How I may call Keychail APIs using .Net Core on MacOs.
There are no APIs in .NET Core that directly expose / that map 1:1 with Keychain. If you need to access such APIs directly, you would need to write your own P/Invokes, or find a library that's already done it.
Closing as answered.
Do .Net core gives any support to create asymmetric keys? like Ecdsa. And we want to save them in key chain so that later on we can retrieve them for further use. As you have stated in this link that, from v2.0, you are using Apple Security Framework on macOS.
We have implemented it on Windows using CNG Nuget, but unable to find on MacOS.
Please advice.
Did you look at our crypto APIs in System.Security namespace?
@bartonjs @krwq may be able to tell more
BTW: You may want to create new issue if @bartonjs does not answer ... in general we do not monitor closed issues and this is somewhat different question than the original one.
Yes I have looked into System.Security namespace, but unable to find required APIs.
I will wait for @bartonjs & @krwq response, otherwise I will create a new thread.
Keys can be created (e.g. ECDsa.Create()), but not persisted into a keychain. The only way to persist a key into a keychain is by having it paired to a certificate in a PFX/PKCS#12 file and then importing it with X509KeyStorageFlags.PersistKeySet (that'll import the cert and key into the default keychain).
Actually, you can do it easier by just adding the cert (with a paired key) to new X509Store(StoreName.My, StoreLocation.CurrentUser, OpenFlags.ReadWrite), that's also the default keychain.
But you can't open a macOS key by identifier, or save a key with a controlled identifier.
It's working. Thanks.
Most helpful comment
Actually, you can do it easier by just adding the cert (with a paired key) to
new X509Store(StoreName.My, StoreLocation.CurrentUser, OpenFlags.ReadWrite), that's also the default keychain.But you can't open a macOS key by identifier, or save a key with a controlled identifier.