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 support for clearing old certificates during reconnect #919

Merged
merged 2 commits into from
Sep 4, 2024

Conversation

TobZip
Copy link
Contributor

@TobZip TobZip commented Sep 4, 2024

The Options object does not provide a way to remove once added certificates.
This leads to that in case of certificate renewals the connection needs to be closed and recreated, including recreating all subscriptions. Just adding the new certificate and trying to reconnect with the old no longer relevant certificate and the new certificate in the certificate collection will make the connection fail on the TLS handshake.

Without a way to clear the certificates, reflection is required to get access to the internal certificates field which can be problematic.

By enabling library user to clear the certificates field through ClearCertificates() and adding the new certificate, the connection can use the correct certificate during the next connection retry (if retrial is configured).
This can be done for example in a user provided ReconnectDelayHandler method.

Other changes:

  • fixed some typos
  • added missing usage of nameof()

Copy link
Collaborator

@scottf scottf left a comment

Choose a reason for hiding this comment

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

So I'm not going to accept this because it's not necessary. Just make another Options. I do like the other changes, the comment fixes and the nameof for instance, so you are welcome to resubmit with only those changes.

/// <param name="nkeySeedText">The text containing the "-----BEGIN USER NKEY SEED-----" block or the seed begining with "SU".
/// May be the same as the jwt string if they are chained.</param>
/// <param name="nkeySeedText">The text containing the "-----BEGIN USER NKEY SEED-----" block or the seed beginning with "SU".
/// Maybe the same as the jwt string if they are chained.</param>
Copy link
Collaborator

Choose a reason for hiding this comment

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

"May be" was correct here. How about, "Both string can contain both the credentials and jwt block since they will be parsed for the required data."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not have time to make this change according to your suggestion before this PR was merged.
Do you want me to make a new PR to fix this?

Copy link
Collaborator

Choose a reason for hiding this comment

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

sorry for the slow response, yeah, please fix when you get a chance. I'll make a release as soon as you do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same here, sorry for the even slower response. Will make a new PR this week.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PR is now created: #925

Copy link
Collaborator

@scottf scottf left a comment

Choose a reason for hiding this comment

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

LGTM

@scottf scottf merged commit 0c829d6 into nats-io:main Sep 4, 2024
1 check passed
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