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

Hermes supports JRE truststore #1196

Merged
merged 6 commits into from
Apr 24, 2020
Merged

Conversation

jewertow
Copy link
Contributor

@jewertow jewertow commented Apr 13, 2020

Background context

Hermes documentation says that hermes-consumers use JRE trust store to verify the ssl certificates, but in fact hermes-consumers use provided key store and trust store. It should work also with JRE trust store ($JAVA_HOME/jre/lib/security/cacerts).

Changes

  • consumer.ssl.enabled is enabled by default

Frontend and Consumers allow to configure source of key store and trust store.
There are new configuration properties:

  • {consumers,frontend}.ssl.{key,trust}store.source - can be set to jre (default) or provided
    In case of provided Hermes loads provided key/trust store from specified location ({consumer,frontend}.ssl{key,trust}store.location)
    In case of jre Hermes loads trust store from $JAVA_HOME/jre/lib/security/jssecacerts or $JAVA_HOME/jre/lib/security/cacerts.

@jewertow jewertow changed the title Hermes supports default JVM truststore [WIP] Hermes supports default JVM truststore Apr 13, 2020
@@ -122,18 +122,30 @@
FRONTEND_SSL_PORT("frontend.ssl.port", 8443),
FRONTEND_SSL_CLIENT_AUTH_MODE("frontend.ssl.client.auth.mode", "not_requested"),
FRONTEND_SSL_PROTOCOL("frontend.ssl.protocol", "TLS"),

FRONTEND_SSL_KEYSTORE_DEFAULT_JVM("frontend.ssl.keystore.default.jvm", true),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not sure whether this name is comprehensible.
Maybe frontend.ssl.keystore.jvm.based would be more appropriate...?

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder If this should be a string type property (enum-like), say:
frontend.ssl.keystore.source, with default value equal to jvmDefault (the other option would be provided).
In this case there would be no possibility for empty value (both are false), plus no need for guessing which option has higher priority when both are set to true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor Author

@jewertow jewertow Apr 15, 2020

Choose a reason for hiding this comment

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

@dankraw since we load trust store from JRE path maybe {consumer,frontend}.ssl.{key,trust}store.source=jre would be better name for this property?

Copy link
Contributor

Choose a reason for hiding this comment

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

jre sounds alright. :)

FRONTEND_SSL_TRUSTSTORE_LOCATION("frontend.ssl.truststore.location", "classpath:server.truststore"),
FRONTEND_SSL_TRUSTSTORE_PASSWORD("frontend.ssl.truststore.password", "password"),
FRONTEND_SSL_TRUSTSTORE_FORMAT("frontend.ssl.truststore.format", "JKS"),

CONSUMER_SSL_ENABLED("consumer.ssl.enabled", false),
CONSUMER_SSL_PROTOCOL("consumer.ssl.protocol", "TLS"),
CONSUMER_SSL_ENABLED("consumer.ssl.enabled", true),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since property consumer.http2.enabled is enabled by default it should also be enabled.

HttpClient client = new HttpClient(createSslContextFactory());
HttpClient client = sslContextFactoryProvider.provideSslContextFactory()
.map(sslContextFactory -> new HttpClient(sslContextFactory))
.orElseGet(() -> new HttpClient());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It could be simplified to:

.map(HttpClient::new)
.orElseGet(HttpClient::new);

but I think it would be less understandable.
What is your opinion?

Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer the committed version. :)

HttpClient client = new HttpClient(transport, createSslContextFactory());
HttpClient client = sslContextFactoryProvider.provideSslContextFactory()
.map(sslContextFactory -> new HttpClient(transport, sslContextFactory))
.orElseThrow(() -> new IllegalStateException("Cannot create http/2 client due to lack of ssl context factory"));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is reasonable behaviour because http/2 client should be created only when both ssl and http/2 are enabled.

@@ -67,27 +62,6 @@ public void shouldPublishUsingOkHttpClient() {
runTestSuiteForHermesClient(client);
}

@Test
public void shouldPublishUsingOkHttpClientUsingSSL() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see any difference between this test and shouldCommunicateWithHermesUsingHttp2. I decided to remove it.

@jewertow jewertow changed the title [WIP] Hermes supports default JVM truststore Hermes supports JRE truststore Apr 15, 2020
@jewertow jewertow merged commit ebdffc0 into master Apr 24, 2020
benzwreck pushed a commit to benzwreck/hermes that referenced this pull request Apr 24, 2020
benzwreck pushed a commit to benzwreck/hermes that referenced this pull request Apr 24, 2020
benzwreck pushed a commit to benzwreck/hermes that referenced this pull request Jun 14, 2020
pwolaq pushed a commit to pwolaq/hermes that referenced this pull request Oct 15, 2020
@piotrrzysko piotrrzysko deleted the hermes-supports-default-jvm-truststore branch February 22, 2021 10:55
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

Successfully merging this pull request may close these issues.

3 participants