The handshake failed due to unexpected packet format

Sep 29, 2008 at 4:57 PM

I am trying to perform a HTTPS post operation to send a transaction using HTTPWebRequest

I have the following error when I try to instantiate the streamwriter with :
myWriter = new StreamWriter(objRequest.GetRequestStream());

"The handshake failed due to unexpected packet format."

This is my code:
protected void test_Click(object sender, EventArgs e)
    {

        myPage.Text = readHtmlPage("https://test.authorize.net/test.dll");

          }

    private string readHtmlPage(string url)
    {
        String result = "";
        String strPost = "x_login=6m5N4Et&x_tran_key=92t27t5&x_method=CC&x_type=AUTH_ONLY&x_amount=0.01&x_delim_data=TRUE&x_delim_char=|&x_relay_response=FALSE&x_card_num=4111111111111111&x_exp_date=052009&x_test_request=TRUE&x_version=3.1";
        StreamWriter myWriter = null;

        HttpWebRequest objRequest = (HttpWebRequest)WebRequest.Create(url);

        objRequest.Method = "POST";
        objRequest.ContentLength = strPost.Length;
        objRequest.ContentType = "application/x-www-form-urlencoded";

 

        try
        {
//I get the error on this line: "The handshake failed due to unexpected packet format."
            myWriter = new StreamWriter(objRequest.GetRequestStream());
            myWriter.Write(strPost);
        }
        catch (Exception e)
        {
            return e.Message;
        }
        finally
        {
            myWriter.Close();
        }

        HttpWebResponse objResponse = (HttpWebResponse)objRequest.GetResponse();
        using (StreamReader sr =
           new StreamReader(objResponse.GetResponseStream()))
        {
            result = sr.ReadToEnd();

            // Close and clean up the StreamReader
            sr.Close();
        }
        return result;

    }
}

----

In web.config, I have:
<system.net>

  <defaultProxy>

   <proxy   proxyaddress="MyProxyaddess"  />

  </defaultProxy>

 </system.net>

and on IIS 5.1, I created a server certificate.

Thanks.