lemon-sh / IRCrarria

A very simple IRC<->Terraria chat bridge for TShock.
GNU General Public License v3.0
6 stars 3 forks source link

Exception when trying to use TLS #1

Closed ncfavier closed 3 years ago

ncfavier commented 3 years ago
System.InvalidOperationException: Operation is not valid due to the current state of the object.
  at Mono.Net.Security.AsyncProtocolRequest.InnerRead (System.Threading.CancellationToken cancellationToken) [0x000cd] in <3d97dda773a54430b892e1d794e5d921>:0
  at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (System.Threading.CancellationToken cancellationToken) [0x00093] in <3d97dda773a54430b892e1d794e5d921>:0
  at Mono.Net.Security.AsyncProtocolRequest.StartOperation (System.Threading.CancellationToken cancellationToken) [0x0008b] in <3d97dda773a54430b892e1d794e5d921>:0
  at Mono.Net.Security.MobileAuthenticatedStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, System.Boolean checkCertificateRevocation) [0x0004b] in <3d97dda773a54430b892e1d794e5d921>:0
  at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.AuthenticateAsClient(string,System.Security.Cryptography.X509Certificates.X509CertificateCollection,System.Security.Authentication.SslProtocols,bool)
  at System.Net.Security.SslStream.AuthenticateAsClient (System.String targetHost, System.Security.Cryptography.X509Certificates.X509CertificateCollection clientCertificates, System.Security.Authentication.SslProtocols enabledSslProtocols, System.Boolean checkCertificateRevocation) [0x00006] in <3d97dda773a54430b892e1d794e5d921>:0
  at System.Net.Security.SslStream.AuthenticateAsClient (System.String targetHost) [0x00007] in <3d97dda773a54430b892e1d794e5d921>:0
  at IrcDotNet.StandardIrcClient.GetDataStream (System.Boolean useSsl, System.String targetHost) [0x00020] in <ed7eaffe2fcc4c6ea20ec5fa81278eb7>:0
  at IrcDotNet.StandardIrcClient.ConnectCompleted (System.Object sender, System.Net.Sockets.SocketAsyncEventArgs e) [0x0005b] in <ed7eaffe2fcc4c6ea20ec5fa81278eb7>:0
  at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted (System.Net.Sockets.SocketAsyncEventArgs e) [0x0000e] in <3d97dda773a54430b892e1d794e5d921>:0
  at System.Net.Sockets.SocketAsyncEventArgs.Complete_internal () [0x00009] in <3d97dda773a54430b892e1d794e5d921>:0
  at System.Net.Sockets.Socket+<>c.<.cctor>b__366_6 (System.IAsyncResult ares) [0x00057] in <3d97dda773a54430b892e1d794e5d921>:0
  at System.Net.Sockets.SocketAsyncResult+<>c.<Complete>b__27_0 (System.Object state) [0x0000b] in <3d97dda773a54430b892e1d794e5d921>:0
  at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem () [0x00008] in <03536ee47e5c4ceba0005cfa8de28fe9>:0
  at System.Threading.ThreadPoolWorkQueue.Dispatch () [0x00074] in <03536ee47e5c4ceba0005cfa8de28fe9>:0
  at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback () [0x00000] in <03536ee47e5c4ceba0005cfa8de28fe9>:0

Tried this on two different networks (Libera and Rizon).

I'm using NixOS unstable, mono 6.12.0.90, TShock 4.5.5.

ncfavier commented 3 years ago

This is probably an IrcDotNet issue, but I can't find a related issue there.

Maybe you could try updating to IrcDotNet 0.7.0?

lemon-sh commented 3 years ago

Hello!

Unfortunately, I had some issues with the IrcDotNet library after it has migrated to the dotnet cli toolchain. I am planning on removing that dependency though and rewriting the IRC protocol handling from scratch. I can reproduce this issue on Linux but not on Windows, seems to be an issue with IrcDotNet's TCP socket call misuse.

Thank you for submitting this issue and letting me know.

lemon-sh commented 3 years ago

Hello again, @ncfavier.

Over the past 2 days I was working on an experimental implementation of the embedded IRC framework. I have confirmed it to work with SSL on both Linux and Windows. Could you give it a try? It's available on the releases page as a pre-release. Make sure that your ircrarria.toml file matches the one that is in the develop branch readme.

ncfavier commented 3 years ago

Thanks for the quick implementation! Everything seems to work now.

skip_cert_validation should probably default to false though.

lemon-sh commented 3 years ago

yup I changed that an hour ago

ncfavier commented 3 years ago

I mean be optional and default to false

lemon-sh commented 3 years ago

Oh that makes sense. I will do that. Thanks for your contribution!