Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silent exceptions in TcpConnection #1005

Open
xPaw opened this issue Jul 22, 2021 · 1 comment
Open

Silent exceptions in TcpConnection #1005

xPaw opened this issue Jul 22, 2021 · 1 comment

Comments

@xPaw
Copy link
Member

xPaw commented Jul 22, 2021

Specifically here:

try
{
NetMsgReceived?.Invoke( this, new NetMsgEventArgs( packData, CurrentEndPoint! ) );
}
catch (Exception ex)
{
log.LogDebug( "TcpConnection", "Unexpected exception propogated back to NetLoop: {0}", ex);
}

I'm trying NET6 preview 6, and for whatever reason it's throwing here:

NetFilterEncryptionWithHMAC Unable to decrypt incoming packet: NetFilterEncryption was unable to decrypt packet: HMAC from server did not match computed HMAC.
TcpConnection Unexpected exception propogated back to NetLoop: System.IO.IOException: Unable to decrypt incoming packet
 ---> System.Security.Cryptography.CryptographicException: NetFilterEncryption was unable to decrypt packet: HMAC from server did not match computed HMAC.

The problem is that this exception is being hidden by TcpConnection and only visible in DebugLog. Should it be rethrown/not caught?

@azuisleet
Copy link
Member

Since EnvelopeEncryptedConnection is already responsible for shutting down connections based on the connection setup state, and is directly responsible for calling ProcessIncoming, it should probably also catch this IOException (or a subclass of it) and abort the connection.

void OnNetMsgReceived( object sender, NetMsgEventArgs e )
{
if (state == EncryptionState.Encrypted)
{
var plaintextData = encryption!.ProcessIncoming( e.Data );
NetMsgReceived?.Invoke( this, e.WithData( plaintextData ) );
return;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants