X-rus / xNet

xNet - class library for .NET Framework
MIT License
271 stars 219 forks source link

Problem with connection. Failed to establish SSL connection with the HTTP server #54

Open xerasy opened 7 years ago

xerasy commented 7 years ago
request.UserAgent = useragent;
request.IgnoreProtocolErrors = true;
request.SslCertificateValidatorCallback += (sender, certificate, chain, sslPolicyErrors) => true;

var result = request.Get("https://sscasino.online/");

but i get error Failed to establish SSL connection with the HTTP server

i get the same the error for WebRequest

  WebRequest req = WebRequest.Create(Url);
  WebResponse resp = req.GetResponse();
  Stream stream = resp.GetResponseStream();
  StreamReader sr = new StreamReader(stream);
  string Out = sr.ReadToEnd();
  sr.Close();

but solution for WebRequest is a add line ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

what is the solution for xnet ?

Fedorus commented 6 years ago

Looks like its a SslStream issue. Put in on HttpRequests.cs on line ~2595 sslStream.AuthenticateAsClient(address.Host, null, SslProtocols.Tls12, false);

instead default line sslStream.AuthenticateAsClient(...)

ghost commented 6 years ago

Yes! you must set "request.SslCertificateValidatorCallback += delegate" return true

angelocart commented 5 years ago

Replacing the line sslStream.AuthenticateAsClient(...) with sslStream.AuthenticateAsClient(address.Host, null, SslProtocols.Tls12, false); returns an error of "SslProtocols' does not contain a definition for 'Tls12'.

Please fix, thanks!

Fedorus commented 5 years ago

Replacing the line sslStream.AuthenticateAsClient(...) with sslStream.AuthenticateAsClient(address.Host, null, SslProtocols.Tls12, false); returns an error of "SslProtocols' does not contain a definition for 'Tls12'.

Please fix, thanks!

This repository no more supported. Try this one: https://github.com/Fedorus/xNetStandard

Its for .netStandart. Lost all operations connected with winAPI plus GZip connections (some error with GZipStream in .net Core).

angelocart commented 5 years ago

Thank you for the response! I will let you know if any other errors occur.

Does the previous documentation for xNet apply to the new repository?

Fedorus commented 5 years ago

Thank you for the response! I will let you know if any other errors occur.

Does the previous documentation for xNet apply to the new repository?

There was no breakink changes in API, but there may be bugs in fixes that I`ve described above

angelocart commented 5 years ago

Thank you for the response! I will let you know if any other errors occur. Does the previous documentation for xNet apply to the new repository?

There was no breakink changes in API, but there may be bugs in fixes that I`ve described above

Okay. Thank you again for the quick reply.

angelocart commented 5 years ago

@Fedorus I use Visual Studio 2015. I cannot open the project files for xNetStandart so I cannot build the DLL file. Could you build the DLL and upload it?

Fedorus commented 5 years ago

@Fedorus I use Visual Studio 2015. I cannot open the project files for xNetStandart so I cannot build the DLL file. Could you build the DLL and upload it?

here xNetStandart.zip

angelocart commented 5 years ago

@Fedorus I use Visual Studio 2015. I cannot open the project files for xNetStandart so I cannot build the DLL file. Could you build the DLL and upload it?

here xNetStandart.zip

Much appreciated. Have a good day!

AnErrupTion commented 5 years ago

This issue has been fixed with Better-xNet. https://github.com/AnErrupTion/Better-xNet @xerasy

mathewsun commented 4 years ago

Replacing the line sslStream.AuthenticateAsClient(...) with sslStream.AuthenticateAsClient(address.Host, null, SslProtocols.Tls12, false); returns an error of "SslProtocols' does not contain a definition for 'Tls12'.

Please fix, thanks!

sslStream.AuthenticateAsClient(address.Host, null, (SslProtocols)3072, true);

SoheilMV commented 4 years ago

This issue has been fixed with MVNet. Supports TLS / SSL https://github.com/SoheilMV/MVNet