Skip to content

Fix connections to server on different locales #329

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

Merged
merged 1 commit into from
Nov 22, 2023
Merged

Conversation

Noonlord
Copy link
Contributor

ToUpper is not enough, we need to use InvariantCulture to be sure that the string is converted to uppercase in a way that is consistent with the server.

 * ToUpper is not enough, we need to use InvariantCulture to be sure
   that the string is converted to uppercase in a way that is
   consistent with the server.
@Noonlord
Copy link
Contributor Author

@Zerpet I would like to have a review if possible.

Copy link

codecov bot commented Nov 21, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (90a6752) 92.60% compared to head (4601429) 92.49%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #329      +/-   ##
==========================================
- Coverage   92.60%   92.49%   -0.11%     
==========================================
  Files         113      113              
  Lines        9964     9946      -18     
  Branches      825      825              
==========================================
- Hits         9227     9200      -27     
- Misses        560      567       +7     
- Partials      177      179       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Gsantomaggio
Copy link
Member

Thank you @Noonlord.
May I ask for an example where the current implementation fails?

Copy link
Member

@Zerpet Zerpet left a comment

Choose a reason for hiding this comment

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

I echo Gabriele's thought. Where does the current implementation fail?

From what I read in Microsoft documentation, the upper invariant seems important for consistent sorting. However, we are not sorting the authentication mechanism array, we just iterate it.

@Noonlord
Copy link
Contributor Author

Noonlord commented Nov 21, 2023

Current implemention fails when culture is set to Turkish. "Plain".ToUpper() produces PLAİN instead of PLAIN, which results in failing string comparation. Code throws "Sasl mechanism Plain is not supported by the server"
IMG_7215
IMG_7216

@Gsantomaggio
Copy link
Member

@Noonlord That's interesting.
Can I ask for the configuration file ?
I was trying with:

auth_mechanisms.1 = PLAİN
auth_mechanisms.2 = AMQPLAIN
auth_mechanisms.3 = EXTERNAL

loopback_users.guest = false

ssl_options.cacertfile = ../certs/ca_certificate.pem
ssl_options.certfile = ../certs/server_certificate.pem
ssl_options.keyfile = ../certs/server_key.pem
listeners.ssl.default = 5671
stream.listeners.ssl.default = 5551
ssl_options.verify               = verify_peer
ssl_options.fail_if_no_peer_cert = true

But PLAİN does not appear on the Mechanisms list. I don't see problems merging the PR. I am curios about reproducing the issue locally.

Thank you

@Noonlord
Copy link
Contributor Author

@Gsantomaggio although I can not provide you a configuration file at the moment, I can show something else to reproduce the bug locally.

This is the current culture:
resim (2)

This is the auth mechanisms response from server:
resim (1)

And this is the client parameters:
resim

Issue is from client parameters authentication method enumeration, Plain, converts to string as "Plain" and using TR-tr culture ToUpper() method transforms this into "PLAİN" those two strings get compared and it results to false, because of this client thinks that server does not support "Plain" authentication method.

Thanks for quick responses!

@Zerpet
Copy link
Member

Zerpet commented Nov 22, 2023

Thank you for the detailed explanation and the contribution!

@Zerpet Zerpet merged commit b237f59 into rabbitmq:main Nov 22, 2023
@Zerpet Zerpet added this to the v1.7.5 milestone Nov 22, 2023
@Zerpet Zerpet added the bug Something isn't working label Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants