예제 #1
0
        public static bool BindSslCertToPorts(IPEndPoint endPoint, string sslCertPath)
        {
            //
            // To verify run this at the command prompt:
            //
            // netsh http show sslcert ipport=0.0.0.0:1236
            //
            var cert     = new X509Certificate(sslCertPath);
            var certHash = cert.GetCertHashString();
            var args     = string.Format("http add sslcert ipport={0}:{1} appid={{12345678-db90-4b66-8b01-88f7af2e36bf}} certhash={2}",
                                         endPoint.Address, endPoint.Port, certHash);

            return(ProcessHost.Invoke(null, "netsh.exe", args));
        }
예제 #2
0
        public void EnsureAccessToPort(string url)
        {
            var args = string.Format("http add urlacl url={0}/ user=\\Everyone", url);

            try
            {
                bool invoke = ProcessHost.Invoke(null, "netsh.exe", args);
                if (!invoke)
                {
                    Dev2Logger.Log.Error(string.Format("There was an error adding url: {0}", url));
                }
            }
            catch (Exception e)
            {
                Dev2Logger.Log.Error(e);
            }
        }
예제 #3
0
        public bool EnsureSslCertificate(string certPath, IPEndPoint endPoint)
        {
            var result     = false;
            var asmLoc     = Location;
            var exeBase    = string.Empty;
            var authName   = AuthorityName();
            var masterData = string.Empty;
            var workingDir = string.Empty;

            try
            {
                if (!string.IsNullOrEmpty(asmLoc))
                {
                    asmLoc     = Path.GetDirectoryName(asmLoc);
                    workingDir = String.Concat(asmLoc, @"\SSL Generation");
                    exeBase    = string.Concat(asmLoc, MakeCertPath);
                    masterData = File.ReadAllText(exeBase);
                    var writeBack = string.Format(masterData, authName);

                    File.WriteAllText(exeBase, writeBack);
                }

                if (ProcessHost.Invoke(workingDir, "CreateCertificate.bat", null))
                {
                    result = BindSslCertToPorts(endPoint, certPath);
                }
            }
            catch (Exception e)
            {
                Dev2Logger.Error(e, GlobalConstants.WarewolfError);
            }
            finally
            {
                if (!string.IsNullOrEmpty(masterData))
                {
                    File.WriteAllText(exeBase, masterData);
                }
            }

            return(result);
        }