Exemplo n.º 1
0
        public static void Log(bool wasCached, SPDYResult result, String ip)
        {
            try
            {
                System.IO.File.AppendAllText(logfile, MakeCSV(
                                                                DateTime.Now,
                                                                ip,
                                                                result.Hostname,
                                                                (wasCached) ? "=CACHED=" : "-",
                                                                result.ConnectivityHTTP,
                                                                result.ConnectivitySSL,
                                                                result.SpeaksSSL,
                                                                result.SSLCertificateValid,
                                                                result.HasNPNExtension,
                                                                result.SupportsSPDY,
                                                                result.RedirectsToSSL) + Environment.NewLine);
            }
            catch (Exception)
            {

            }
        }
Exemplo n.º 2
0
        public static SPDYResult Test(string hostname, int port, int mSecTimeout, String clientIP)
        {
            SPDYResult result = new SPDYResult(hostname, port);

            SimpleRequestor requestor = new SimpleRequestor(clientIP);

            SimpleResponse resp = null;

            //check #1, do they have SSL?
            SSLInspector inspector = new SSLInspector(hostname, port);

            inspector.Inspect(mSecTimeout);

            result.ConnectivitySSL = inspector.ConnectivityWorks;
            result.SpeaksSSL = inspector.SpeaksSSL;
            result.Protocol = inspector.ProtocolUsed;

            if(inspector.SpeaksSSL)
            {

                //gather info on the SSL cert errors
                result.CertErrors.AddRange(inspector.CertificateErrors);

                ServerHello serverHello = TlsHandshaker.ExchangeHellos(hostname, port, inspector.ProtocolUsed, mSecTimeout);

                if (serverHello != null)
                {
                    result.HasNPNExtension = serverHello.HasNPNExtension;
                    result.SPDYProtocols.AddRange(serverHello.NPNProtocols);
                    result.HasALPNExtension = serverHello.HasALPNExtension;
                    result.ALPNProtocols.AddRange(serverHello.ALPNProtocols);
                }

                //lets check the HTTP headers of the SSL website, to get the server header and test for HSTS support.
                requestor.Timeout = 9000;
                resp = requestor.Head("https://" + hostname + ":" + port + "/");
                if (resp != null)
                {
                    result.SSLServerHeader = resp.GetHeaderValue("Server");
                    result.HstsHeader = resp.GetHeaderValue("Strict-Transport-Security");
                }

            }

            //check to see what a request to port 80 does
            requestor.Timeout = 9000;
            resp = requestor.Head("http://" + hostname + "/");
            if (resp != null)
            {
                result.ConnectivityHTTP = true;

                //if an SSL server exists
                if (result.SpeaksSSL)
                {
                    //does a request to 80 automatically redirect us?
                    if (resp.ResponseURL.Scheme == "https" && resp.ResponseURL.Host.ToLower().Contains(hostname))
                    {
                        result.RedirectsToSSL = true;
                    }
                }
                else
                {
                    //no SSL, so grab the Server header if its there to determine if the server might be able to support SPDY
                    result.HTTPServerHeader = resp.GetHeaderValue("Server");
                }
            }

            return result;
        }