Esempio n. 1
0
        /// <summary>
        /// Retrieves a page from a Web server, using a simple GET request.
        /// </summary>
        public static void Main()
        {
            // Root CA Certificate needed to validate HTTPS servers.
            byte[] ca = Resource1.GetBytes(
                Resource1.BinaryResources.VerisignCA);

            X509Certificate[] caCerts =
                new X509Certificate[] { new X509Certificate(ca) };

            // Initialize the default webproxy to be used by all
            // HttpWebRequests.
            // Change the proxy address to fit your environment.
            HttpWebRequest.DefaultWebProxy =
                new WebProxy("itgproxy.dns.microsoft.com", true);

            // Print the HTTP data from each of the following pages.
            PrintHttpData("http://autos.msn.com/default.aspx", null);
            PrintHttpData("http://www.nytimes.com/", null);

            // Test SSL connection with no certificate verification
            PrintHttpData("https://www.google.com/accounts/ManageAccount/", null);

            // Read from secure webpages by using the Verisign Root CA
            // certificate that is stored in the Resource1.resx file.
            PrintHttpData("https://www.google.com/accounts/ManageAccount/",
                          caCerts);
        }
Esempio n. 2
0
        /// <summary>
        /// Retrieves a page from a Web server, using a simple GET request.
        /// </summary>
        public static void Main()
        {
            Microsoft.SPOT.Hardware.Utility.SetLocalTime(new DateTime(2011, 4, 14));

            // Wait for DHCP (on LWIP devices)
            while (true)
            {
                IPAddress ip = IPAddress.GetDefaultLocalAddress();

                if (ip != IPAddress.Any)
                {
                    break;
                }

                Thread.Sleep(1000);
            }

            // Root CA Certificate needed to validate HTTPS servers.
            byte[] ca = Resource1.GetBytes(
                Resource1.BinaryResources.VerisignCA);

            X509Certificate[] caCerts =
                new X509Certificate[] { new X509Certificate(ca) };

            // Initialize the default webproxy to be used by all
            // HttpWebRequests.
            // Change the proxy address to fit your environment.
            HttpWebRequest.DefaultWebProxy =
                new WebProxy("itgproxy.dns.microsoft.com", true);

            // Print the HTTP data from each of the following pages.
            PrintHttpData("http://autos.msn.com/default.aspx", null);
            PrintHttpData("http://www.nytimes.com/", null);

            // Test SSL connection with no certificate verification
            PrintHttpData("https://www.google.com/accounts/ManageAccount/", null);

            // Read from secure webpages by using the Verisign Root CA
            // certificate that is stored in the Resource1.resx file.
            PrintHttpData("https://www.google.com/accounts/ManageAccount/",
                          caCerts);
        }