This discussion is archived
1 Reply Latest reply: Mar 12, 2009 2:23 AM by 686347 RSS

HTTPS does not works via WebCache

686347 Newbie
Currently Being Moderated
When I try to get request using this code (C#)
class MyTrustPolicy : ICertificatePolicy {
   public bool CheckValidationResult(ServicePoint srvPoint, 
                                                 X509Certificate certificate, 
                                                 WebRequest request, int certificateProblem) {
        return true;
   }
}
class Program {
    static void Main(string[] args){
        ServicePointManager.CertificatePolicy = new MyTrustPolicy();

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://my.test.server");
        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        Stream stream = response.GetResponseStream(); // here it craches.

        int len = 4096;
        byte[] buffer = new byte[len];
        int count = 0;
        do {
            count = stream.Read(buffer, 0, len);
            if (count != 0) {
            Console.WriteLine(Encoding.UTF8.GetString(buffer, 0, count));
        } while (count > 0);
        Console.ReadKey();
    }
And I get
Unhandled Exception: System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream.

When I connect to "https://my.test.server:4444" (directly, not using web cache), - all works ok. Browsers also works fine. How to fetch page?

Thanks.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points