Skip to content

[feat] Enable hostname verification by default#20268

Closed
michaeljmarshall wants to merge 50 commits into
apache:masterfrom
michaeljmarshall:enable-hostname-verification-by-default
Closed

[feat] Enable hostname verification by default#20268
michaeljmarshall wants to merge 50 commits into
apache:masterfrom
michaeljmarshall:enable-hostname-verification-by-default

Conversation

@michaeljmarshall

Copy link
Copy Markdown
Member

PIP: This will require a PIP. It is a draft for now while I get tests passing.

Motivation

It is recommended to use hostname verification in most use cases for TLS. In order to have more secure defaults, I propose that we enable TLS hostname verification by default.

This change will not affect any users that do not have TLS enabled. It will only be a breaking change for users that want to use TLS with hostname verification disabled.

Modifications

  • Update all clients to enable hostname verification by default.

Verifying this change

This is a trivial change from a configuration perspective. I expect many tests will fail though, so those will also verify the changes.

Does this pull request potentially affect one of the following parts:

  • The default values of configurations

Documentation

  • doc-required

Matching PR in forked repository

PR in forked repository: michaeljmarshall#44

@michaeljmarshall michaeljmarshall added area/client area/broker area/security doc-required Your PR changes impact docs and you will update later. labels May 9, 2023
@michaeljmarshall michaeljmarshall added this to the 3.1.0 milestone May 9, 2023
@michaeljmarshall michaeljmarshall self-assigned this May 9, 2023
@hezhangjian

Copy link
Copy Markdown
Member

+1. I think it's appropriate that the default secure behavior is better for protecting users.

@eolivelli eolivelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1 very well

@Parameter(names = "--tls-allow-insecure", description = "Allow insecure tls connection #Java, Python")
protected boolean tlsAllowInsecureConnection;
// for backwards compatibility purposes
@Parameter(names = "--hostname_verification_enabled",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It seems we should keep the --hostname_verification_enabled flag for backward compatibility.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The backwards compatibility has to break because we are moving --hostname-verification-enabled to arity 1. As such, users will need to update scripts in order anyway, so it seems like a reasonable time to drop the deprecated parameter.

Note: we have to switch to arity 1 because otherwise JCommander will invert the meaning of the boolean flag and changing the default value will be the opposite of what users expect. See https://jcommander.org/#_boolean

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for your explanation! When the --hostname-verification-enabled with arity = 1, we must set a value after this flag. This change is incompatible with the old usage.

LGTM

@nodece nodece Jul 22, 2023

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add this change and usage to PR body?

cmd.add("--tls-enable-hostname-verification");
}
cmd.add("--tls-enable-hostname-verification");
cmd.add(String.valueOf(authConfig.isTlsHostnameVerificationEnable()));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you add the default value to AuthenticationConfig?

    @Builder.Default
    private boolean tlsHostnameVerificationEnable = true;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Great point, I should update that field. Does updating that definition change these lines of code too?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Your current approach is correct.

@Technoboy- Technoboy- modified the milestones: 3.1.0, 3.2.0 Jul 31, 2023
@github-actions

Copy link
Copy Markdown

The pr had no activity for 30 days, mark with Stale label.

@github-actions github-actions Bot added the Stale label Aug 31, 2023
@Technoboy- Technoboy- modified the milestones: 3.2.0, 3.3.0 Dec 22, 2023
@coderzc coderzc modified the milestones: 3.3.0, 3.4.0 May 8, 2024
@tisonkun

tisonkun commented May 8, 2024

Copy link
Copy Markdown
Member

Closed as stale and conflict.

@tisonkun tisonkun closed this May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants