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

Add TLS end to end unit test #1

Merged
merged 2 commits into from
May 31, 2024

Conversation

Arkatufus
Copy link

No description provided.

Copy link
Owner

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some very minor feedback but otherwise LGTM

@@ -18,4 +18,8 @@ public sealed record ClientTlsOptions
public bool UseTls { get; init; } = false;

public SslClientAuthenticationOptions? SslOptions { get; init; }

public RemoteCertificateValidationCallback? ServerCertificateValidator { get; set; }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are both built into SslClientAuthenticationOptions https://learn.microsoft.com/en-us/dotnet/api/system.net.security.sslclientauthenticationoptions?view=net-8.0#properties - let's use those properties instead

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -53,6 +53,9 @@ public MqttClientFactory(ActorSystem system)
public async Task<IMqttClient> CreateTcpClient(MqttClientConnectOptions options, MqttClientTcpOptions tcpOptions)
{
AssertMqtt311(options);
if (tcpOptions.TlsOptions is { UseTls: true, SslOptions: null })
throw new NullReferenceException("TlsOptions.SslOptions can not be null if TlsOptions.UseTls is true");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

public SslServerAuthenticationOptions? SslOptions { get; set; }
public SslServerAuthenticationOptions? SslOptions { get; init; }

public RemoteCertificateValidationCallback? ClientCertificateValidator { get; init; }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same feedback as earlier - SslServerAuthenticationOptions also contains these properties: https://learn.microsoft.com/en-us/dotnet/api/system.net.security.sslserverauthenticationoptions?view=net-8.0 - let's use those

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -0,0 +1,17 @@
-----BEGIN CERTIFICATE REQUEST-----
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did my old certs not work correctly?

Copy link
Author

@Arkatufus Arkatufus May 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also needed the self-signed root CA certificate that signs the server certificate, that's why I needed to rebuild all of the certs

}

[Fact]
public async Task ShouldAutomaticallyReconnectAndSubscribeAfterServerDisconnect()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better if we just made the TCP end 2 end specs sub-classable and reuse those @Arkatufus ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can give that a try

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Aaronontheweb Aaronontheweb merged commit 3b53dee into Aaronontheweb:tls-support May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants