Example #1
0
 /// <summary>
 /// UpdateCertificatesACL method implementation
 /// </summary>
 public bool UpdateCertificatesACL(KeyMgtOptions options)
 {
     try
     {
         return(_manager.UpdateCertificatesACL(options));
     }
     catch (Exception e)
     {
         _log.WriteEntry(string.Format("Error on WebAdminService Service UpdateCertificatesACL ACL method : {0}.", e.Message), EventLogEntryType.Error, 2010);
         return(false);
     }
 }
 /// <summary>
 /// ApplyCertificatesACL method implementation
 /// </summary>
 public bool UpdateCertificatesACL(KeyMgtOptions options)
 {
     try
     {
         return(SIDs.internalUpdateCertificatesACLs(options));
     }
     catch (Exception e)
     {
         _log.WriteEntry(string.Format("Error on WebAdminService Service ApplyCertificatesACL ACL method : {0}.", e.Message), EventLogEntryType.Error, 2010);
         throw e;
     }
 }
Example #3
0
        /// <summary>
        /// UpdateCertificatesACL method implementation
        /// </summary>
        public static bool UpdateCertificatesACL(KeyMgtOptions options)
        {
            WebAdminClient manager = new WebAdminClient();

            manager.Initialize();
            try
            {
                IWebAdminServices client = manager.Open();
                try
                {
                    return(client.UpdateCertificatesACL(options));
                }
                finally
                {
                    manager.Close(client);
                }
            }
            finally
            {
                manager.UnInitialize();
            }
        }
 /// <summary>
 /// UpdateCertificatesACL method implementation
 /// </summary>
 internal static bool UpdateCertificatesACL(KeyMgtOptions options = KeyMgtOptions.AllCerts)
 {
     return(WebAdminManagerClient.UpdateCertificatesACL(options));
 }
Example #5
0
        /// <summary>
        /// InternalUpdateCertificatesACLs method implementation
        /// </summary>
        internal static bool InternalUpdateCertificatesACLs(KeyMgtOptions options = KeyMgtOptions.AllCerts)
        {
            X509Store store = new X509Store(StoreName.My, StoreLocation.LocalMachine);

            store.Open(OpenFlags.MaxAllowed);
            try
            {
                X509Certificate2Collection collection2 = (X509Certificate2Collection)store.Certificates;
                foreach (X509Certificate2 x509 in collection2)
                {
                    string fileName = string.Empty;
                    try
                    {
                        bool doit = options.Equals(KeyMgtOptions.AllCerts);
                        if (options.HasFlag(KeyMgtOptions.MFACerts))
                        {
                            if (x509.Subject.ToLower().StartsWith("cn=mfa rsa keys") || x509.Subject.ToLower().StartsWith("cn=mfa sql key"))
                            {
                                doit = true;
                            }
                        }
                        if (options.HasFlag(KeyMgtOptions.ADFSCerts))
                        {
                            if (x509.Subject.ToLower().StartsWith("cn=adfs"))
                            {
                                doit = true;
                            }
                        }
                        if (options.HasFlag(KeyMgtOptions.SSLCerts))
                        {
                            if (x509.Subject.ToLower().StartsWith("cn=*."))
                            {
                                doit = true;
                            }
                        }
                        if (doit)
                        {
                            var rsakey = x509.GetRSAPrivateKey();
                            if (rsakey is RSACng)
                            {
                                fileName = ((RSACng)rsakey).Key.UniqueName;
                            }
                            else if (rsakey is RSACryptoServiceProvider)
                            {
                                fileName = ((RSACryptoServiceProvider)rsakey).CspKeyContainerInfo.UniqueKeyContainerName;
                            }
                            if (!string.IsNullOrEmpty(fileName))
                            {
                                char   sep = Path.DirectorySeparatorChar;
                                string rsamachinefullpath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + sep + "Microsoft" + sep + "Crypto" + sep + "RSA" + sep + "MachineKeys" + sep + fileName;
                                // string rngmachinefullpath = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + sep + "Microsoft" + sep + "Crypto" + sep + "Keys" + sep + fileName;

                                if (File.Exists(rsamachinefullpath))
                                {
                                    InternalUpdateFilesACLs(rsamachinefullpath);
                                }

                                /* if (File.Exists(rngmachinefullpath))
                                 * {
                                 *   InternalUpdateFilesACLs(rngmachinefullpath);
                                 * } */
                            }
                        }
                    }
                    catch
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                store.Close();
            }
            return(true);
        }