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

Trailing dot in URL causes TLS failure #740

Closed
REBELinBLUE opened this issue Sep 27, 2023 · 2 comments
Closed

Trailing dot in URL causes TLS failure #740

REBELinBLUE opened this issue Sep 27, 2023 · 2 comments

Comments

@REBELinBLUE
Copy link

REBELinBLUE commented Sep 27, 2023

Adding a dot to the end of the URL is valid, it tells DNS that it is an absolute fully-qualified domain name, this is a common trick in Kubernetes to prevent it from trying to resolve the address locally first due to /etc/resolv.conf having ndots set to 5 (i.e. domains with less than 5 dots try to resolve locally). https://pracucci.com/kubernetes-dns-resolution-ndots-options-and-why-it-may-affect-application-performances.html as seen in Solution 1 here for example.

This works fine in ampqlib, however, when you are using TLS it does not and you get an error Error: Client network socket disconnected before secure TLS connection was established

This is because in connect.js the following code

    sockopts.host = url.hostname;
    sockopts.servername = url.hostname;

servername is the servername for the SNI TLS Extension, and in SNI the servername must not have a trailing dot https://datatracker.ietf.org/doc/html/rfc6066#section-3

You can see here how curl strips it curl/curl@5de8d84

Happy to submit a PR

@cressie176
Copy link
Collaborator

Hi @REBELinBLUE,

Thank you for the detailed analysis. Very happy to accept a PR.

@REBELinBLUE
Copy link
Author

REBELinBLUE commented Sep 27, 2023

@cressie176 I see you may have already fixed it in 318a682 by allowing the servername to be supplied separately, looks like it was fixed in #697

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

No branches or pull requests

2 participants