Skip to content

KAFKA-2656: Remove hardcoded default key and truststores#312

Closed
rajinisivaram wants to merge 2 commits into
apache:trunkfrom
rajinisivaram:KAFKA-2656
Closed

KAFKA-2656: Remove hardcoded default key and truststores#312
rajinisivaram wants to merge 2 commits into
apache:trunkfrom
rajinisivaram:KAFKA-2656

Conversation

@rajinisivaram

Copy link
Copy Markdown
Contributor

Removed default hardcoded keystore and truststore in /tmp so that default JVM keystore/truststore may be used when keystore/truststore is not specified in Kafka server or client properties

@ijuma

ijuma commented Oct 15, 2015

Copy link
Copy Markdown
Member

Thanks for the PR. What happens if no keystore or truststore is configured via any of the mechanisms? Will the user get a helpful message? If not, then we may want to change SSLFactory to provide a helpful message, in that case (assuming it's not hard to do).

Also, looking at the SSLFactory code, I am not sure checkKeyStoreConfigs is actually useful. Also, we don't have an equivalent checkTruststoreConfigs. Maybe worth checking that code and simplifying it at the same time.

@ijuma

ijuma commented Oct 15, 2015

Copy link
Copy Markdown
Member

Also, if you're willing, I noticed that the following are unused in SSLConfigs:

SSL_NEED_CLIENT_AUTH_DOC
DEFAULT_SSL_NEED_CLIENT_AUTH

It would be good to remove them.

@ijuma

ijuma commented Oct 15, 2015

Copy link
Copy Markdown
Member

Sorry, I noticed one more thing. The messages in the exceptions thrown by createKeystore and createTruststore don't match the conditions.

@rajinisivaram

Copy link
Copy Markdown
Contributor Author

@ijuma Thank you for the review. I will remove SSL_NEED_CLIENT_AUTH properties in SSLConfig and fix the exception messages.

The checks in checkKeyStoreConfigs dont do anything useful because the keys are always present even the value is null. Since null checks are performed in createKeystore anyway, I will remove checkKeyStoreConfigs.

Java uses $JAVA_HOME/lib/security/cacerts as default keystore and truststore if the stores are not explicitly configured and no system properties are specified. We would like to use the default truststore part of this so that our customer's clients dont have to set a truststore at all.

The default keystore is of less value. Even before this PR, the code was falling back to default keystore for clients since keystore is optional unless server has client-auth turned on. So on the client side, the code is fine as is.

On the server side, we do always need a valid keystore. If one is not specified and the default is used, handshake would fail unless the default cacerts contains a valid keypair or the javax.net.ssl.keyStore property is set. And the user would need to debug the problem in the same way as mismatched client/server certificates. I dont think we should any additional checks of cacerts file itself other than what Java does anyway. The question is whether we should always mandate that keystore is explicitly specified in Kafka configs for Kafka server when SSL is enabled. Or should we simply fall back to the JVM system defaults? What do you think?

@ijuma

ijuma commented Oct 15, 2015

Copy link
Copy Markdown
Member

I agree with your assessment @rajinisivaram.

Regarding the server side keystore, I can see pros and cons for each option. Maybe it's easier to be consistent and fallback to the JVM system defaults while doing a good job of logging what we're doing to make it easy for users to diagnose configuration problems if they occur.

It would be good to get @junrao's and @harshach's opinions too.

@junrao

junrao commented Oct 15, 2015

Copy link
Copy Markdown
Contributor

LGTM. @harshach , do you want to take a look?

@ijuma

ijuma commented Oct 19, 2015

Copy link
Copy Markdown
Member

@rajinisivaram, thanks, your changes look good so far. One thing I noticed though is that in KafkaConfig.channelConfigs, we add items to a map without checking if they are null. This means that for items that don't have a default value (like in this example) we get inconsistent behaviour between get() == null and containsKey. I think we need to do something like the following for optional keys that don't have a default value:

if (sslKeystoreLocation == null)
  channelConfigs.put(SSLKeystoreLocationProp, sslKeystoreLocation)

Does this make sense?

@ijuma

ijuma commented Oct 19, 2015

Copy link
Copy Markdown
Member

I'm fixing the issue with null values in channelConfigs in the SASL branch and it doesn't affect current usage, so your change LGTM.

@junrao can this be merged?

@rajinisivaram

Copy link
Copy Markdown
Contributor Author

@ijuma Yes, null check will be good. Thank you for making the changes in the SASL branch.

@ijuma

ijuma commented Oct 19, 2015

Copy link
Copy Markdown
Member

Jenkins is reporting an unrelated CopyCat failure, which means all the core and client tests passed.

@asfgit asfgit closed this in 6745435 Oct 19, 2015
efeg pushed a commit to efeg/kafka that referenced this pull request Jan 29, 2020
hachikuji added a commit to hachikuji/kafka that referenced this pull request May 6, 2020
hachikuji added a commit to hachikuji/kafka that referenced this pull request May 6, 2020
abbccdda pushed a commit to abbccdda/kafka that referenced this pull request May 31, 2020
hachikuji added a commit to hachikuji/kafka that referenced this pull request Aug 5, 2020
hachikuji added a commit to hachikuji/kafka that referenced this pull request Aug 13, 2020
wyuka pushed a commit to wyuka/kafka that referenced this pull request Mar 23, 2022
TICKET = DATAPIPES-23596
LI_DESCRIPTION =
Empty partitions set in NoOffsetForPartitionException causes brooklin test failure. Populate partitions set with partitionFetchStates

(ported from 2.4-li branch)
wyuka pushed a commit to wyuka/kafka that referenced this pull request Mar 28, 2022
TICKET = DATAPIPES-23596
LI_DESCRIPTION =
Empty partitions set in NoOffsetForPartitionException causes brooklin test failure. Populate partitions set with partitionFetchStates

(ported from 2.4-li branch)
wyuka pushed a commit to wyuka/kafka that referenced this pull request Jun 16, 2022
TICKET = DATAPIPES-23596
LI_DESCRIPTION =
Empty partitions set in NoOffsetForPartitionException causes brooklin test failure. Populate partitions set with partitionFetchStates

(ported from 2.4-li branch)
davide-armand pushed a commit to aiven/kafka that referenced this pull request Dec 1, 2025
Avoid using source that may not be available on some shell environments.
jeqo added a commit to aiven/kafka that referenced this pull request Jan 16, 2026
Avoid using source that may not be available on some shell environments.
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