Handle explicit disablement of management SSL correctly

Closes gh-9423
This commit is contained in:
Andy Wilkinson 2017-06-07 13:57:59 +01:00
parent 223b694d3a
commit 9579e95868
2 changed files with 12 additions and 1 deletions

View File

@ -163,7 +163,7 @@ public class EndpointWebMvcAutoConfiguration
} }
if (managementPort == ManagementServerPort.SAME) { if (managementPort == ManagementServerPort.SAME) {
if (new RelaxedPropertyResolver(this.applicationContext.getEnvironment(), if (new RelaxedPropertyResolver(this.applicationContext.getEnvironment(),
"management.ssl.").getProperty("enabled") != null) { "management.ssl.").getProperty("enabled", Boolean.class, false)) {
throw new IllegalStateException( throw new IllegalStateException(
"Management-specific SSL cannot be configured as the management " "Management-specific SSL cannot be configured as the management "
+ "server is not listening on a separate port"); + "server is not listening on a separate port");

View File

@ -558,6 +558,17 @@ public class EndpointWebMvcAutoConfigurationTests {
this.applicationContext.refresh(); this.applicationContext.refresh();
} }
@Test
public void samePortCanBeUsedWhenManagementSslIsExplicitlyDisabled()
throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext,
"management.ssl.enabled=false");
this.applicationContext.register(RootConfig.class, EndpointConfig.class,
BaseConfiguration.class, EndpointWebMvcAutoConfiguration.class,
ErrorMvcAutoConfiguration.class, ServerPortConfig.class);
this.applicationContext.refresh();
}
@Test @Test
public void managementServerCanDisableSslWhenUsingADifferentPort() throws Exception { public void managementServerCanDisableSslWhenUsingADifferentPort() throws Exception {
EnvironmentTestUtils.addEnvironment(this.applicationContext, EnvironmentTestUtils.addEnvironment(this.applicationContext,