![]() |
|
[C#] C# Help With HttpWebRequest [Authentication failed] - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C#] C# Help With HttpWebRequest [Authentication failed] (/showthread.php?tid=6004720) |
C# Help With HttpWebRequest [Authentication failed] - draxyee - Sep 3, 2019 Hi, I am getting this error upon sending this request: "Authentication failed because the remote party has closed the transport stream" Code public static bool RegisterAccount(Account acc, CookieContainer ck)I have tried almost everything but nothing helps. (links have been replaced with [dot] - full code; pastebin . com/raw/ZbieRH56 Hopefully someone can help me with this! Draxyee RE: C# Help With HttpWebRequest [Authentication failed] - vaiperboy - Sep 3, 2019 -post a snippet of the original request made by our browser -why not httpclient - Code if (resp.StatusCode == HttpStatusCode.Found) { return true; } else { return false; }this makes no fucking sense, just do Code return resp.StatusCode == HttpStatusCode.Found;i could probably go more a lot in the code, but before that just post a snippet of the actual http request RE: C# Help With HttpWebRequest [Authentication failed] - draxyee - Sep 5, 2019 (Sep 3, 2019 10:20 AM)vaiperboy Wrote: -post a snippet of the original request made by our browser Full request: regex101 . com/r/2Zsdc3/1 Also, thanks a lot for that tip on returning true/false, that's really helpful 👍 - Draxyee RE: C# Help With HttpWebRequest [Authentication failed] - draxyee - Sep 8, 2019 Could anyone help me with this? :) RE: C# Help With HttpWebRequest [Authentication failed] - gigajew - Sep 8, 2019 You’re urlencodjng your whole post data. Aren’t the keys getting encoded then too? Just a thought I could be wrong RE: C# Help With HttpWebRequest [Authentication failed] - draxyee - Sep 8, 2019 (Sep 8, 2019 07:22 AM)gigajew Wrote: You’re urlencodjng your whole post data. Aren’t the keys getting encoded then too? Just a thought I could be wrong URL Encode is just for the application/x-www-form-urlencoded RE: C# Help With HttpWebRequest [Authentication failed] - 0xDEAD10CC - Sep 8, 2019 (Sep 8, 2019 11:58 AM)draxyee Wrote: URL Encode is just for the application/x-www-form-urlencoded What he's saying is that is not how URL encoding works. You are only supposed to encode the keys and values, not the common separators like = and &. You sure this is right? Code if (acc.Proxy == null) { registerReq.Proxy = acc.Proxy; }RE: C# Help With HttpWebRequest [Authentication failed] - draxyee - Sep 9, 2019 (Sep 8, 2019 05:57 PM)0xDEAD10CC Wrote: What he's saying is that is not how URL encoding works. You are only supposed to encode the keys and values, not the common separators like = and &. I see. Yes that line is right. I set proxy to null if string is empty. I don't think that's why there's an issue though. RE: C# Help With HttpWebRequest [Authentication failed] - 0xDEAD10CC - Sep 9, 2019 (Sep 9, 2019 03:55 PM)draxyee Wrote: I see. That makes absolutely no sense. What if it has a value? It never sets the proxy anyways since it is a local variable... RE: C# Help With HttpWebRequest [Authentication failed] - draxyee - Sep 10, 2019 (Sep 9, 2019 04:46 PM)0xDEAD10CC Wrote: That makes absolutely no sense. What if it has a value? It never sets the proxy anyways since it is a local variable... I've tried playing with proxies but it has no difference in whether the request will throw the error I mentioned. Thanks again. RE: C# Help With HttpWebRequest [Authentication failed] - MavenGradle - Sep 10, 2019 (Sep 9, 2019 03:55 PM)draxyee Wrote: I see. No it is not 'right' in any way shape or form. Your proxy can only be null in your code! Don't you see that? That line of code does absolutely nothing but consume CPU cycles and should be removed entirely. In any case, this seems to be an issue related to TLS mismatch. You need to make sure that the required cipher suites are enabled in Windows and configured properly in your .NET environment and code: https://docs.microsoft.com/en-us/dotnet/framework/network-programming/tls Read that and then look at your code in which you do this: Code ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;Code registerReq.ProtocolVersion = HttpVersion.Version11;RE: C# Help With HttpWebRequest [Authentication failed] - n0$f3ratu$ - Sep 10, 2019 (Sep 10, 2019 01:08 PM)MavenGradle Wrote: This! without the Ssl3. You don't need that. Just add that line in the constructor and you should be fine. RE: C# Help With HttpWebRequest [Authentication failed] - MavenGradle - Sep 10, 2019 (Sep 10, 2019 01:15 PM)n0$f3ratu$ Wrote: This! without the Ssl3. I was actually trying to make the point that with the more recent versions of the .NET Framework, you should no longer do things like that and simply let the .NET Framework use the OS default settings. By recent, I mean .NET 4.7 which was released almost 3 years ago. |