Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
error:

HTTP/1.1 502 Proxy Error ( The specified Secure Sockets Layer (SSL) port is not allowed. ISA Server is not configured to allow SSL requests from this port. Most Web browsers use port 443 for SSL requests. )
code:
C#
private Socket ConnectByHTTP(string v_sHost, int v_iPort, string v_sProxyHost, int v_iProxyPort, string v_sUserName, string v_sPassword)
        {
            Socket mSocket = DirectConnect(v_sProxyHost, v_iProxyPort); 
            if (mSocket.Connected)
            {
                byte[] end = new byte[] { 13, 10 };
                string sEnd = Encoding.Default.GetString(end);

                byte[] user = Encoding.Default.GetBytes(v_sUserName + ":" + v_sPassword);
                string sUser = Convert.ToBase64String(user, 0, user.Length, Base64FormattingOptions.InsertLineBreaks);
               // v_iPort = 443;
                String msg = "CONNECT" + " " + v_sHost + ":" + v_iPort.ToString() + " " + "HTTP/1.1" + sEnd
                    //  + "Host: " + v_sProxyHost + ":" + v_iProxyPort.ToString() + sEnd
                    //+ "Authorization: Basic " + sUser + sEnd + sEnd;
                    //  + "Proxy-Authorization: Basic " + sUser + sEnd + sEnd;
                + "User-Agent: MyApp/0.1" + sEnd + sEnd;

                byte[] buff = Encoding.Default.GetBytes(msg);
                mSocket.Send(buff, buff.Length, SocketFlags.None);

                buff = new byte[4096];
                mSocket.Receive(buff, 4096, SocketFlags.None);

                string str = Encoding.Default.GetString(buff);

                if (str.StartsWith("HTTP") == true && str.IndexOf("200") > 0)
                    return mSocket;
                else
                    return null;
            }
            else
                return null;            
        }
Posted
Updated 20-Mar-12 21:09pm
v2
Comments
ZurdoDev 21-Mar-12 8:05am    
Is there a question? The error is telling you to use port 443 for SSL traffic. So what is the issue?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900