Opc.Ua.CertificateStoreIdentifier.DetermineStoreType C# (CSharp) Method

DetermineStoreType() public static method

Detects the type of store represented by the path.
public static DetermineStoreType ( string storePath ) : string
storePath string
return string
        public static string DetermineStoreType(string storePath)
        {
            if (String.IsNullOrEmpty(storePath))
            {
                return CertificateStoreType.Directory;
            }

            if (storePath.StartsWith("LocalMachine\\", StringComparison.OrdinalIgnoreCase))
            {
                return CertificateStoreType.Windows;
            }

            if (storePath.StartsWith("CurrentUser\\", StringComparison.OrdinalIgnoreCase))
            {
                return CertificateStoreType.Windows;
            }

            if (storePath.StartsWith("User\\", StringComparison.OrdinalIgnoreCase))
            {
                return CertificateStoreType.Windows;
            }

            if (storePath.StartsWith("Service\\", StringComparison.OrdinalIgnoreCase))
            {
                return CertificateStoreType.Windows;
            }

            return CertificateStoreType.Directory;
        }

Usage Example

コード例 #1
0
        /// <summary>
        /// Opens the store.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <returns>The store.</returns>
        public static ICertificateStore OpenStore(string path)
        {
            ICertificateStore store = CertificateStoreIdentifier.CreateStore(CertificateStoreIdentifier.DetermineStoreType(path));

            store.Open(path);
            return(store);
        }