Search code examples
c#.net-corex509certificate2

Where is certificate saved when adding to cert store in Linux


Using .Net Core 2.1, Linux

var store = new X509Store(StoreName.Root, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadWrite);
storeRoot.Add(cert);
storeRoot.Close();
  1. Where does the actual certificate get saved in the file system please? I have checked in "/etc/ssl/certs" but cannot identify my cert and so I am not sure if it's stored in there!

  2. Is it possible to create an in-memory store? If so, how? Thanks


Solution

  • 1) This is considered a detail of the platform, and you shouldn't ever depend on it, and it's subject to change at any time. (But it's easily findable as ~/.dotnet/corefx/cryptography/x509stores/root in current versions). Adding or modifying files in this directory (or any of the directories under ~/.dotnet/corefx/cryptography/) can break the product.

    2) X509Certificate2Collection? An "in-memory store" is either just a collection, or you're doing something with interop. X509Store on Linux doesn't have a native representation, so there's no interop possibility.