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

Allow custom TLS cert checks #6432

Merged
merged 3 commits into from
Oct 24, 2018
Merged

Conversation

jon-wei
Copy link
Contributor

@jon-wei jon-wei commented Oct 8, 2018

This PR adds an extension point, TLSCertificateChecker, for custom TLS certificate checking (both client and server side).

The hook provided allows an extension to replace the default X509ExtendedTrustManager's checkClientTrusted and checkServerTrusted methods (the default trust manager is provided as a parameter, so the standard checks can still be used by an extension if desired).

This PR also adds an option to the simple-client-sslcontext extension to disable the standard hostname validation check.

Copy link
Member

@clintropolis clintropolis left a comment

Choose a reason for hiding this comment

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

Overall LGTM 🤘

@Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@BindingAnnotation
public @interface Server
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't seem to be used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, removed the unused annotation

customCertCheckRouterUrl = props.get("router_no_client_auth_url");
if (customCertCheckRouterUrl == null) {
String customCertCheckRouterHost = props.get("router_no_client_auth_host");
if (null != customCertCheckRouterHost) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: i find this kind of jarring since outer is var == null and then inside it's flipped to null != var, but I don't think it's a big deal

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hm, it follows the convention for the other nodes in that file, i'll leave this unchanged in this PR

Copy link
Member

Choose a reason for hiding this comment

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

👍

@gianm gianm self-assigned this Oct 15, 2018
@jon-wei
Copy link
Contributor Author

jon-wei commented Oct 16, 2018

TeamCity failures seem unrelated

@gianm gianm removed their assignment Oct 18, 2018
@jon-wei
Copy link
Contributor Author

jon-wei commented Oct 23, 2018

fixed conflicts

customCertCheckRouterUrl = props.get("router_no_client_auth_url");
if (customCertCheckRouterUrl == null) {
String customCertCheckRouterHost = props.get("router_no_client_auth_host");
if (null != customCertCheckRouterHost) {
Copy link
Member

Choose a reason for hiding this comment

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

👍

TrustManager[] newTrustManagers = new TrustManager[trustManagers.length];

for (int i = 0; i < trustManagers.length; i++) {
if (trustManagers[i] instanceof X509ExtendedTrustManager) {
Copy link
Member

Choose a reason for hiding this comment

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

Would it be harmful to just leave non X509ExtendedTrustManager implementations in this list with an else that doesn't wrap them in the CustomCheckX509TrustManager and just adds them to newTrustManagers as is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed this to preserve non-X509ExtendedTrustManager objects and log their presence

Copy link
Contributor

@jihoonson jihoonson left a comment

Choose a reason for hiding this comment

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

LGTM with a nit.


|Property|Description|Default|Required|
|--------|-----------|-------|--------|
|`druid.tls.certificateChecker`|Type name of custom TLS certificate checker, provided by extensions.|"default"|no|
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this supposed to be the canonical class name of the custom checker? I think it would be better to clarify it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added some clarification here

Copy link
Member

@clintropolis clintropolis left a comment

Choose a reason for hiding this comment

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

LGTM 🤘

@jihoonson jihoonson merged commit b2d9b6f into apache:master Oct 24, 2018
jon-wei added a commit to implydata/druid-public that referenced this pull request Oct 26, 2018
* Allow custom TLS cert checks

* PR comment

* Checkstyle, PR comment
gianm pushed a commit to implydata/druid-public that referenced this pull request Nov 16, 2018
* Allow custom TLS cert checks

* PR comment

* Checkstyle, PR comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants