Example #1
0
        /// <summary>
        /// Central store path for certificates. Returns exception if not configured or cannot be returned.
        /// </summary>
        public static string CentralStorePath(ILoggerInterface logger)
        {
            if (!CentralStoreEnabled())
            {
                throw new Exception(
                          "IIS Central store path not enabled or installed. Please check https://blogs.msdn.microsoft.com/kaushal/2012/10/11/central-certificate-store-ccs-with-iis-8-windows-server-2012/");
            }

            string certStoreLocation = Convert.ToString(UtilsRegistry.GetRegistryKeyValue64(
                                                            RegistryHive.LocalMachine,
                                                            "SOFTWARE\\Microsoft\\IIS\\CentralCertProvider",
                                                            "CertStoreLocation",
                                                            string.Empty));

            if (string.IsNullOrWhiteSpace(certStoreLocation))
            {
                throw new Exception("IIS Central store location not configured");
            }

            var resolvedCertStoreLocation = certStoreLocation;

            if (UtilsJunction.IsJunctionOrSymlink(certStoreLocation))
            {
                resolvedCertStoreLocation = UtilsJunction.ResolvePath(resolvedCertStoreLocation);
            }

            if (UtilsSystem.IsNetworkPath(resolvedCertStoreLocation))
            {
                logger.LogWarning(true, "Central Certificate Store Path is located on a network share [{0}]. This has proven to be unstable as CCS will cache corrupted certificates when it is unable to read from the network share.", certStoreLocation);
            }

            return(certStoreLocation);
        }
Example #2
0
 /// <summary>
 /// Clear top-down junctions or links in a directory structure
 /// </summary>
 /// <param name="directory"></param>
 private static void DeleteJunctionsOrLinks(string directory)
 {
     foreach (var dir in Directory.EnumerateDirectories(directory, "*", SearchOption.TopDirectoryOnly))
     {
         if (UtilsJunction.IsJunctionOrSymlink(dir))
         {
             UtilsJunction.DeleteJunctionOrSymlink(dir);
         }
         else
         {
             DeleteJunctionsOrLinks(dir);
         }
     }
 }
Example #3
0
        /// <summary>
        /// If path is a junction or symlink, remove it.
        /// </summary>
        /// <param name="path"></param>
        public static void RemoveJunction(string path)
        {
            var linkmanager = ReparsePointFactory.Create();

            // On a local folder based deployment we might be redeploying on top of same application...
            if (Directory.Exists(path))
            {
                var type = linkmanager.GetLinkType(path);

                if (type == LinkType.Junction ||
                    type == LinkType.Symbolic ||
                    type == LinkType.HardLink)
                {
                    UtilsJunction.DeleteJunctionOrSymlink(path);
                }
            }
        }