ToString() public method

public ToString ( ) : string
return string
Ejemplo n.º 1
0
        public static string CleanUpSni(this Binding binding)
        {
#if !IIS
            if (!binding.GetIsSni())
            {
                return(string.Empty);
            }
#endif
            try
            {
                var hash = binding.CertificateHash == null ? string.Empty : Hex.ToHexString(binding.CertificateHash);
                // remove sni mapping
                using (var process = new Process())
                {
                    var start = process.StartInfo;
                    start.Verb            = "runas";
                    start.UseShellExecute = true;
                    start.FileName        = "cmd";
                    start.Arguments       =
                        $"/c \"\"{CertificateInstallerLocator.FileName}\" /h:\"{hash}\" /s:{binding.CertificateStoreName}\" /i:{AppIdIisExpress} /o:{binding.EndPoint.Port} /x:{binding.Host}";
                    start.CreateNoWindow = true;
                    start.WindowStyle    = ProcessWindowStyle.Hidden;
                    process.Start();
                    process.WaitForExit();

                    if (process.ExitCode != 0)
                    {
                        return("Remove SNI certificate failed: access is denied");
                    }

                    return(string.Empty);
                }
            }
            catch (Win32Exception ex)
            {
                // elevation is cancelled.
                if (ex.NativeErrorCode != NativeMethods.ErrorCancelled)
                {
                    RollbarLocator.RollbarInstance.Error(ex, new Dictionary <string, object> {
                        { "native", ex.NativeErrorCode }
                    });
                    return($"Remove SNI certificate failed: unknown (native {ex.NativeErrorCode})");
                }

                return("Remove SNI certificate failed: operation is cancelled");
            }
            catch (NullReferenceException ex)
            {
                RollbarLocator.RollbarInstance.Error(ex, new Dictionary <string, object> {
                    { "binding", binding.ToString() }, { "endpointNull", binding.EndPoint == null }
                });
                return($"Remove SNI certificate failed: unknown ({ex.Message})");
            }
            catch (Exception ex)
            {
                RollbarLocator.RollbarInstance.Error(ex);
                return($"Remove SNI certificate failed: unknown ({ex.Message})");
            }
        }
Ejemplo n.º 2
0
        internal bool?FindDuplicate(Binding binding, Site host, Binding existing)
        {
            foreach (Site site in this)
            {
                foreach (Binding item in site.Bindings)
                {
                    if (item.Protocol == binding.Protocol && item.ToString() == binding.ToString() && item != existing)
                    {
                        return(site == host ? (bool?)null : true);
                    }
                }
            }

            return(false);
        }