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

Reject misconfigured/ambiguous SSL server config #45892

Merged
merged 12 commits into from
Nov 7, 2019

Conversation

tvernum
Copy link
Contributor

@tvernum tvernum commented Aug 23, 2019

This commit makes it an error to start a node where either of the
server contexts (xpack.security.transport.ssl and
xpack.security.http.ssl) meet either of these conditions:

  1. The server lacks a certificate/key pair (i.e. neither
    ssl.keystore.path nor ssl.certificate are configured)
  2. The server has some ssl configuration, but ssl.enabled is not
    specified. This new validation does not care whether ssl.enabled is
    true or false (though other validation might), it simply makes it
    an error to configure server SSL without being explicit about
    whether to enable that configuration.

Relates to #49280

This commit makes it an error to start a node where either of the
server contexts (xpack.security.transport.ssl and
xpack.security.http.ssl) meet either of these conditions:

1. The server lacks a certificate/key pair (i.e. neither
   ssl.keystore.path not ssl.certificate are configured)
2. The server has some ssl configuration, but ssl.enabled is not
   specified. This new validation does not care whether ssl.enabled is
   true or false (though other validation might), it simply makes it
   an error to configure server SSL without being explicit about
   whether to enable that configuration.
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security

@tvernum
Copy link
Contributor Author

tvernum commented Aug 23, 2019

This is 8.0 only, as it is a breaking change. I will raise a separate PR to backport to 7.x as a deprecation.

@tvernum
Copy link
Contributor Author

tvernum commented Aug 27, 2019

@elasticmachine update branch

Copy link
Member

@jkakavas jkakavas left a comment

Choose a reason for hiding this comment

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

LGTM, left some suggestions

`xpack.security.http.ssl` without also configuring
`xpack.security.http.ssl.enabled`.

For example, the following configuration is invalid:
Copy link
Member

Choose a reason for hiding this comment

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

Maybe do this example with PEM files to further visually indicate that this doesn't apply only to keystores/truststores?

final SSLConfigurationSettings configurationSettings = SSLConfigurationSettings.withPrefix(prefix + ".");
if (isConfigurationValidForServerUsage(configuration) == false) {
throw new ElasticsearchSecurityException("invalid configuration for " + prefix +
" - a server context requires a key and certificate, but these have not been configured; either [" +
Copy link
Member

Choose a reason for hiding this comment

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

Unsure how clear "server context" is. We could try "server SSL context" or "server SSL configuration" ?

throw new ElasticsearchSecurityException("invalid configuration for " + prefix +
" - a server context requires a key and certificate, but these have not been configured; either [" +
configurationSettings.x509KeyPair.keystorePath.getKey() + "] or [" +
configurationSettings.x509KeyPair.certificatePath.getKey() + "] should be set");
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
configurationSettings.x509KeyPair.certificatePath.getKey() + "] should be set");
configurationSettings.x509KeyPair.keyPath.getKey() + " and " + configurationSettings.x509KeyPair.certificatePath.getKey() + "] should be set");

configurationSettings.x509KeyPair.certificatePath.getKey() + "] should be set");
}
} else if (settings.hasValue(enabledSetting) == false) {
final List<String> sslKeys = settings.keySet().stream()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
final List<String> sslKeys = settings.keySet().stream()
final List<String> sslConfigKeys = settings.keySet().stream()

to make it immediately obvious when looking at the code these are not SSL Keys but configuration keys

Copy link
Contributor

@bizybot bizybot left a comment

Choose a reason for hiding this comment

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

LGTM, Thank you.

@tvernum
Copy link
Contributor Author

tvernum commented Nov 5, 2019

@elasticmachine update branch

@tvernum tvernum merged commit eb3c57b into elastic:master Nov 7, 2019
tvernum added a commit to tvernum/elasticsearch that referenced this pull request Nov 19, 2019
This commit adds a deprecation warning when starting
a node where either of the server contexts
(xpack.security.transport.ssl and xpack.security.http.ssl)
meet either of these conditions:

1. The server lacks a certificate/key pair (i.e. neither
   ssl.keystore.path not ssl.certificate are configured)
2. The server has some ssl configuration, but ssl.enabled is not
   specified. This new validation does not care whether ssl.enabled is
   true or false (though other validation might), it simply makes it
   an error to configure server SSL without being explicit about
   whether to enable that configuration.

Backport of: elastic#45892
tvernum added a commit that referenced this pull request Nov 22, 2019
This commit adds a deprecation warning when starting
a node where either of the server contexts
(xpack.security.transport.ssl and xpack.security.http.ssl)
meet either of these conditions:

1. The server lacks a certificate/key pair (i.e. neither
   ssl.keystore.path not ssl.certificate are configured)
2. The server has some ssl configuration, but ssl.enabled is not
   specified. This new validation does not care whether ssl.enabled is
   true or false (though other validation might), it simply makes it
   an error to configure server SSL without being explicit about
   whether to enable that configuration.

Backport of: #45892
masseyke added a commit that referenced this pull request Sep 3, 2021
…settings (#77092)

In 8.0 we prevent the server from starting up if certain SSL properties are misconfigured or ambiguous. Specifically:
1) The server lacks a certificate/key pair (i.e. neither ssl.keystore.path nor ssl.key/ssl.certificate are configured)
2) The server has some ssl configuration, but ssl.enabled is not specified.
This commit adds a check to the deprecation info API for these changes.
Relates #42404 #45892
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