예제 #1
0
        public static string GetSystemStoreLocation()
        {
#if MONODROID
            return("/system/etc/security/cacerts");
#else
            return(MonoBtlsX509StoreManager.GetStorePath(MonoBtlsX509StoreType.MachineTrustedRoots));
#endif
        }
예제 #2
0
        static void AddMachineStore(MonoBtlsX509Store store)
        {
            var machinePath = MonoBtlsX509StoreManager.GetStorePath(MonoBtlsX509StoreType.MachineTrustedRoots);

            if (Directory.Exists(machinePath))
            {
                store.AddDirectoryLookup(machinePath, MonoBtlsX509FileType.PEM);
            }
        }
예제 #3
0
        static void AddUserStore(MonoBtlsX509Store store)
        {
            var userPath = MonoBtlsX509StoreManager.GetStorePath(MonoBtlsX509StoreType.UserTrustedRoots);

            if (Directory.Exists(userPath))
            {
                store.AddDirectoryLookup(userPath, MonoBtlsX509FileType.PEM);
            }
        }
예제 #4
0
        internal static void SetupCertificateStore(MonoBtlsX509Store store)
        {
#if MONODROID
            store.SetDefaultPaths();
            store.AddAndroidLookup();
#else
            var userPath = MonoBtlsX509StoreManager.GetStorePath(MonoBtlsX509StoreType.UserTrustedRoots);
            if (Directory.Exists(userPath))
            {
                store.AddDirectoryLookup(userPath, MonoBtlsX509FileType.PEM);
            }
            var machinePath = MonoBtlsX509StoreManager.GetStorePath(MonoBtlsX509StoreType.MachineTrustedRoots);
            if (Directory.Exists(machinePath))
            {
                store.AddDirectoryLookup(machinePath, MonoBtlsX509FileType.PEM);
            }
#endif
        }
예제 #5
0
        static void Main(string[] args)
        {
            if (!MonoBtlsProvider.IsSupported())
            {
                Console.Error.WriteLine("BTLS is not supported in this runtime!");
                Environment.Exit(255);
            }

            var configPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);

            configPath = Path.Combine(configPath, ".mono");

            var oldStorePath = Path.Combine(configPath, "certs", "Trust");
            var newStorePath = MonoBtlsX509StoreManager.GetStorePath(MonoBtlsX509StoreType.UserTrustedRoots);

            if (!Directory.Exists(oldStorePath))
            {
                Console.WriteLine("Old trust store {0} does not exist.");
                Environment.Exit(255);
            }

            if (Directory.Exists(newStorePath))
            {
                Directory.Delete(newStorePath, true);
            }
            Directory.CreateDirectory(newStorePath);

            var oldfiles = Directory.GetFiles(oldStorePath, "*.cer");

            Console.WriteLine("Found {0} files in the old store.", oldfiles.Length);

            foreach (var file in oldfiles)
            {
                Console.WriteLine("Converting {0}.", file);
                var data = File.ReadAllBytes(file);
                using (var x509 = MonoBtlsX509.LoadFromData(data, MonoBtlsX509Format.DER)) {
                    ConvertToNewFormat(newStorePath, x509);
                }
            }
        }