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

Hot Reload For Certificate Authentication #1781

Closed
hannasm opened this issue Jun 30, 2023 · 1 comment · Fixed by #1783
Closed

Hot Reload For Certificate Authentication #1781

hannasm opened this issue Jun 30, 2023 · 1 comment · Fixed by #1783
Labels
feature-request New feature or request

Comments

@hannasm
Copy link
Contributor

hannasm commented Jun 30, 2023

During connection establishment an mqtt client might be configured to present a certificate to destination server, verifying it's authenticity. This certificate is currently initialized in the constructor and cannot be changed. Once a client connection is established a certificate does not need to be presented again during normal flow. However, in exceptional cases like network disconnects / reconnects, the client should be able to present an updated certificate.

It appears that the ability to perform hot reloads of a server certificate was recently enabled by using a custom ICertificateProvider interface. (Kudos to @YAJeff who did that in #1652 ).

I am proposing the MqttClient should support a similar ICertificateCollectionProvider interface that would enable hot reload functionality.

Which project is your feature request related to?

  • Client
  • ManagedClient

Describe the solution you'd like

Current MqttClientTlsOptions provides Certificates to the MqttChannelAdapter through List<X509Certificate2> property. These fields are readonly and initialized during construction.

Instead certificates should be provided to the channel from a certificate collection provider interface

public interface ICertificateCollectionProvider {
  IEnumerable<X509Certificate2> GetCertificates();
}

It looks like a connection disconnect / reconnect is handled by creating a new channel so it doesn't appear the channels themselves need to be changed at all, but at least, the adapter factory needs to be calling ICertificateCollectionProvider.GetCertificates()

@hannasm hannasm added the feature-request New feature or request label Jun 30, 2023
@hannasm hannasm changed the title Hot Reload Of Certificate Authentication Hot Reload For Certificate Authentication Jun 30, 2023
@chkr1011 chkr1011 linked a pull request Jul 2, 2023 that will close this issue
@chkr1011
Copy link
Collaborator

chkr1011 commented Jul 2, 2023

I added a new interface as you proposed and added a few more option builders.
Please download the preview version (https://www.myget.org/feed/mqttnet/package/nuget/MQTTnet/4.2.1.820) and let me know if it works.

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

Successfully merging a pull request may close this issue.

2 participants