Esempio n. 1
0
        public static MemoryX509Store LoadCertificates(string folderPath, X509KeyStorageFlags flags)
        {
            if (string.IsNullOrEmpty(folderPath))
            {
                throw new ArgumentException("value was null or empty", "folderPath");
            }

            if (!Directory.Exists(folderPath))
            {
                throw new DirectoryNotFoundException("Directory not found: " + folderPath);
            }

            MemoryX509Store certStore = new MemoryX509Store();

            string[] files = Directory.GetFiles(folderPath);
            for (int i = 0; i < files.Length; ++i)
            {
                string file = files[i];
                string ext  = Path.GetExtension(file) ?? string.Empty;
                ext = ext.ToLower();

                switch (ext)
                {
                default:
                    certStore.ImportKeyFile(file, flags);
                    break;

                case ".pfx":
                    certStore.ImportKeyFile(file, "passw0rd!", flags);
                    break;
                }
            }

            return(certStore);
        }
Esempio n. 2
0
        internal void LoadCerts(MemoryX509Store certStore, string filePath, string password, X509KeyStorageFlags flags)
        {
            string ext = Path.GetExtension(filePath) ?? string.Empty;

            switch (ext.ToLower())
            {
            default:
                certStore.ImportKeyFile(filePath, flags);
                break;

            case ".pfx":
                certStore.ImportKeyFile(filePath, password, flags);
                break;
            }
        }
Esempio n. 3
0
        internal void LoadCerts(MemoryX509Store certStore, X509KeyStorageFlags flags)
        {
            if (!File.Exists(this.FilePath))
            {
                throw new FileNotFoundException("File does not exist", this.FilePath);
            }

            string ext = Path.GetExtension(this.FilePath) ?? string.Empty;

            switch (ext.ToLower())
            {
            default:
                certStore.ImportKeyFile(this.FilePath, flags);
                break;

            case ".pfx":
                certStore.ImportKeyFile(FilePath, this.Password, flags);
                break;
            }
        }