System.Net.CertificateValidationPal.EnsureStoreOpened C# (CSharp) Method

EnsureStoreOpened() private static method

private static EnsureStoreOpened ( X509Store &storeField, StoreLocation storeLocation ) : X509Store
storeField System.Security.Cryptography.X509Certificates.X509Store
storeLocation StoreLocation
return System.Security.Cryptography.X509Certificates.X509Store
        private static X509Store EnsureStoreOpened(ref X509Store storeField, StoreLocation storeLocation)
        {
            X509Store store = Volatile.Read(ref storeField);

            if (store == null)
            {
                lock (s_lockObject)
                {
                    store = Volatile.Read(ref storeField);

                    if (store == null)
                    {
                        try
                        {
                            store = new X509Store(StoreName.My, storeLocation);
                            store.Open(OpenFlags.ReadOnly);

                            Volatile.Write(ref storeField, store);

                            if (NetEventSource.IsEnabled) NetEventSource.Info(null, $"storeLocation: {storeLocation} returned store {store}");
                        }
                        catch (CryptographicException e)
                        {
                            NetEventSource.Fail(null, $"Failed to open cert store, location: {storeLocation} exception {e}");
                            throw;
                        }
                    }
                }
            }

            return store;
        }

Same methods

CertificateValidationPal::EnsureStoreOpened ( bool isMachineStore ) : X509Store