-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Enforce Transport TLS check on all licenses. #79602
Changes from all commits
6d75bf4
d2f17a9
f8d9645
0db55c1
847c2b0
ac77f7d
74c55ec
4d79294
2fd30f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ | |
import org.elasticsearch.cluster.ClusterState; | ||
import org.elasticsearch.cluster.ClusterStateListener; | ||
import org.elasticsearch.cluster.metadata.Metadata; | ||
import org.elasticsearch.cluster.node.DiscoveryNode; | ||
import org.elasticsearch.cluster.service.ClusterService; | ||
import org.elasticsearch.common.component.AbstractLifecycleComponent; | ||
import org.elasticsearch.common.component.Lifecycle; | ||
|
@@ -25,7 +24,6 @@ | |
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.common.time.DateFormatter; | ||
import org.elasticsearch.core.TimeValue; | ||
import org.elasticsearch.discovery.DiscoveryModule; | ||
import org.elasticsearch.env.Environment; | ||
import org.elasticsearch.gateway.GatewayService; | ||
import org.elasticsearch.protocol.xpack.XPackInfoResponse; | ||
|
@@ -243,15 +241,7 @@ public void registerLicense(final PutLicenseRequest request, final ActionListene | |
// because the defaults there mean that security can be "off", even if the setting is "on" | ||
// BUT basic licenses are explicitly excluded earlier in this method, so we don't need to worry | ||
if (XPackSettings.SECURITY_ENABLED.get(settings)) { | ||
// TODO we should really validate that all nodes have xpack installed and are consistently configured but this | ||
// should happen on a different level and not in this code | ||
if (XPackLicenseState.isTransportTlsRequired(newLicense, settings) | ||
&& XPackSettings.TRANSPORT_SSL_ENABLED.get(settings) == false | ||
&& isProductionMode(settings, clusterService.localNode())) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we also remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes we should, thanks! |
||
// security is on but TLS is not configured we gonna fail the entire request and throw an exception | ||
throw new IllegalStateException("Cannot install a [" + newLicense.operationMode() + | ||
"] license unless TLS is configured or security is disabled"); | ||
} else if (XPackSettings.FIPS_MODE_ENABLED.get(settings) | ||
if (XPackSettings.FIPS_MODE_ENABLED.get(settings) | ||
&& false == XPackLicenseState.isFipsAllowedForOperationMode(newLicense.operationMode())) { | ||
throw new IllegalStateException("Cannot install a [" + newLicense.operationMode() + | ||
"] license unless FIPS mode is disabled"); | ||
|
@@ -583,15 +573,6 @@ static License getLicense(final LicensesMetadata metadata) { | |
return null; | ||
} | ||
|
||
private static boolean isProductionMode(Settings settings, DiscoveryNode localNode) { | ||
final boolean singleNodeDisco = "single-node".equals(DiscoveryModule.DISCOVERY_TYPE_SETTING.get(settings)); | ||
return singleNodeDisco == false && isBoundToLoopback(localNode) == false; | ||
} | ||
|
||
private static boolean isBoundToLoopback(DiscoveryNode localNode) { | ||
return localNode.getAddress().address().getAddress().isLoopbackAddress(); | ||
} | ||
|
||
private static List<License.LicenseType> getAllowableUploadTypes() { | ||
return Stream.of(License.LicenseType.values()) | ||
.filter(t -> t != License.LicenseType.BASIC) | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
package org.elasticsearch.xpack.core.ssl; | ||
|
||
import org.elasticsearch.bootstrap.BootstrapCheck; | ||
import org.elasticsearch.bootstrap.BootstrapContext; | ||
import org.elasticsearch.xpack.core.XPackSettings; | ||
|
||
/** | ||
* Bootstrap check to ensure that if we are starting up with security enabled, transport TLS is enabled | ||
*/ | ||
public final class TransportTLSBootstrapCheck implements BootstrapCheck { | ||
@Override | ||
public BootstrapCheckResult check(BootstrapContext context) { | ||
jkakavas marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assert XPackSettings.SECURITY_ENABLED.get(context.settings()) | ||
: "Bootstrap check should not be installed unless security is enabled"; | ||
if (XPackSettings.TRANSPORT_SSL_ENABLED.get(context.settings()) == false) { | ||
return BootstrapCheckResult.failure( | ||
"Transport SSL must be enabled if security is enabled. " | ||
+ "Please set [xpack.security.transport.ssl.enabled] to [true] or disable security by setting " | ||
+ "[xpack.security.enabled] to [false]" | ||
); | ||
} | ||
return BootstrapCheckResult.success(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to check TLS transport and security when installing a new license. If transport TLS is not enabled when security is enabled, then we'd have failed to start the node in the first place ( or we will fail when this moves to production mode - but it is not an effect of the license, as the check applies to all licenses now ) .