Provides an implementation of an X509Store which is backed by files in a directory.
Inheritance: IStorePal
Example #1
0
        public static IStorePal FromSystemStore(string storeName, StoreLocation storeLocation, OpenFlags openFlags)
        {
            if (storeLocation == StoreLocation.CurrentUser)
            {
                if (X509Store.DisallowedStoreName.Equals(storeName, StringComparison.OrdinalIgnoreCase))
                {
                    return(DirectoryBasedStoreProvider.OpenDisallowedStore(openFlags));
                }

                return(new DirectoryBasedStoreProvider(storeName, openFlags));
            }

            Debug.Assert(storeLocation == StoreLocation.LocalMachine);

            if ((openFlags & OpenFlags.ReadWrite) == OpenFlags.ReadWrite)
            {
                throw new CryptographicException(
                          SR.Cryptography_Unix_X509_MachineStoresReadOnly,
                          new PlatformNotSupportedException(SR.Cryptography_Unix_X509_MachineStoresReadOnly));
            }

            // The static store approach here is making an optimization based on not
            // having write support.  Once writing is permitted the stores would need
            // to fresh-read whenever being requested.

            if (X509Store.RootStoreName.Equals(storeName, StringComparison.OrdinalIgnoreCase))
            {
                return(CachedSystemStoreProvider.MachineRoot);
            }

            if (X509Store.IntermediateCAStoreName.Equals(storeName, StringComparison.OrdinalIgnoreCase))
            {
                return(CachedSystemStoreProvider.MachineIntermediate);
            }

            throw new CryptographicException(
                      SR.Cryptography_Unix_X509_MachineStoresRootOnly,
                      new PlatformNotSupportedException(SR.Cryptography_Unix_X509_MachineStoresRootOnly));
        }
Example #2
0
        internal CachedDirectoryStoreProvider(string storeName)
        {
            string storePath = DirectoryBasedStoreProvider.GetStorePath(storeName);

            _storeDirectoryInfo = new DirectoryInfo(storePath);
        }