Skip to content

Extended URI Schemes #685

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

Conversation

gjmwoods
Copy link
Contributor

@gjmwoods gjmwoods commented Mar 2, 2020

This PR makes encryption and trust settings configurable using the URI.

We introduce 4 additional schemes:

  • bolt+s and neo4j+s which enables encryption and configures the trust settings to use the local system's certificate store
  • bolt+ssc and neo4j+ssc which configures trust to use all certificates

@gjmwoods gjmwoods force-pushed the 4-0-encyption-and-trust-config-in-uri branch from eee2fe3 to 7951281 Compare March 3, 2020 09:15
@gjmwoods gjmwoods changed the title Baseline for changes Extended URI Schemes Mar 3, 2020
@gjmwoods gjmwoods force-pushed the 4-0-encyption-and-trust-config-in-uri branch 2 times, most recently from 440e7c6 to 5fe36c1 Compare March 5, 2020 11:14
Comment on lines 143 to 152
if ( isRoutingScheme( scheme ) )
{
return createRoutingDriver( securityPlan, address, connectionPool, eventExecutorGroup, routingSettings, retryLogic, metricsProvider, config );
}
else if ( !isRoutingScheme( scheme ) )
{
case BOLT_URI_SCHEME:
assertNoRoutingContext( uri, routingSettings );
return createDirectDriver( securityPlan, address, connectionPool, retryLogic, metricsProvider, config );
case BOLT_ROUTING_URI_SCHEME:
return createRoutingDriver( securityPlan, address, connectionPool, eventExecutorGroup, routingSettings, retryLogic, metricsProvider, config );
default:
throw new ClientException( format( "Unsupported URI scheme: %s", scheme ) );
}
throw new ClientException( format( "Unsupported URI scheme: %s", scheme ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

haha. I am not fooled by these lines :D
If-else should be good enough here as we've validated the scheme Scheme.validateScheme( uri.getScheme() );.

if( isRoutingScheme(scheme) ){...}
else {...}

@gjmwoods gjmwoods force-pushed the 4-0-encyption-and-trust-config-in-uri branch 4 times, most recently from b93ed99 to 351168a Compare March 5, 2020 15:51
Copy link
Contributor

@zhenlineo zhenlineo left a comment

Choose a reason for hiding this comment

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

All looks good. Just a suggestion to simplify the code.

}
}

private SecurityPlan createSecurityPlanFromScheme( String scheme ) throws GeneralSecurityException, IOException
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we simplify this method as:

if ( isHighTrustScheme(scheme) )
{ 
    return SecurityPlanImpl.forSystemCASignedCertificates( trustStrategy.isHostnameVerificationEnabled() ); 
}
else 
{
    return SecurityPlanImpl.forAllCertificates( trustStrategy.isHostnameVerificationEnabled() );
}

We've already checked isSecurityScheme and assertSecuritySettingsNotUserConfigured.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

of course! I will update this now

…" and "neo4j+ssc" to allow encryption and trust settings to be configurable using the URI.
@gjmwoods gjmwoods force-pushed the 4-0-encyption-and-trust-config-in-uri branch from 351168a to 5f13b09 Compare March 6, 2020 07:54
@zhenlineo zhenlineo merged commit 979f102 into neo4j:4.0 Mar 6, 2020
@gjmwoods gjmwoods deleted the 4-0-encyption-and-trust-config-in-uri branch March 6, 2020 09:26
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.

2 participants