-
Notifications
You must be signed in to change notification settings - Fork 344
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
Fix: client reconnected every authenticationRefreshCheckSeconds when using tls authentication #1062
Conversation
Hi, @jffp113. Thanks for your PR. :) |
Hi @RobertIndie, |
This is the line of code that forces the connection to be reestablished: https://github.com/apache/pulsar/blob/b69f4efa6058c3f51885a61a2b3acb46f8b730f4/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java#L897 |
Hi @jffp113 , Could you share your reproduce steps? |
Hi @RobertIndie, Yes. You need to add authenticationRefreshCheckSeconds config into the broker configuration. You can set for example 30 seconds so that the client can crash fast. authenticationRefreshCheckSeconds forces authentication every x seconds. This is a good practice, for example, a certificate expiry date is only rechecked if there is a refresh authentication. Then you configure simple golang pulsar producer that uses tls authentication. You only need that two steps. I have tested this on pulsar 2.10.3 version. If you need a more detail explanation I'm happy to provide. |
Hi again, I found the line of code in the java client that converts a null/empty auth data to a empty string: |
Unfortunately, I couldn't reproduce it. I used After checking the code, just found that Anyway, I'm +1 for your PR. But I'm trying to reproduce the issue to investigate it further. |
I noticed that we have a custom authentication plugin that does not always return false in Sorry for the confusion. |
@jffp113 Thanks for your explanation. But it doesn't seem to make sense to refresh the tls auth. And it always returns the empty auth data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve your PR because this issue may happen when using the custom authentication provider. And it also makes the behavior consistent with the Java client.
@RobertIndie If want to check if the certificate is still valid we must refresh tls (e.g check the CRL, check expires at field, etc) |
We could make this change generic, and if any provider returns nil we change to []byte{}. |
This would only happen when we reconnect the client connection. But refreshing the authentication won't check the tls certificate.
I'm +1 for this. |
…using tls authentication (apache#1062) ### Motivation When using pulsar tls authentication with a broker that sets the authenticationRefreshCheckSeconds the connection was dropped for each authentication refresh check. After analyzing logs and tcpdumps I concluded that this error appears because the tls authentication is returning null, witch does not pass a validation in the broker. After analyzing the tls auth implementation in Java (that works), I concluded that the GetData method should return empty byte array instead of nil. ### Modifications Changed tls auth GetData to return empty byte array instead of nil. --------- Co-authored-by: Jorge Pereira <jorge.pereira@cross-join.com>
…using tls authentication (#1062) ### Motivation When using pulsar tls authentication with a broker that sets the authenticationRefreshCheckSeconds the connection was dropped for each authentication refresh check. After analyzing logs and tcpdumps I concluded that this error appears because the tls authentication is returning null, witch does not pass a validation in the broker. After analyzing the tls auth implementation in Java (that works), I concluded that the GetData method should return empty byte array instead of nil. ### Modifications Changed tls auth GetData to return empty byte array instead of nil. --------- Co-authored-by: Jorge Pereira <jorge.pereira@cross-join.com> (cherry picked from commit 16a0299)
Motivation
When using pulsar tls authentication with a broker that sets the authenticationRefreshCheckSeconds the connection was dropped for each authentication refresh check. After analyzing logs and tcpdumps I concluded that this error appears because the tls authentication is returning null, witch does not pass a validation in the broker.
After analyzing the tls auth implementation in Java (that works), I concluded that the GetData method should return empty byte array instead of nil.
Modifications
Changed tls auth GetData to return empty byte array instead of nil.
Verifying this change
This change is a trivial rework / code cleanup without any test coverage.
Does this pull request potentially affect one of the following parts:
Documentation