Merge branch '1.3.x'
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
package org.springframework.cloud.consul;
|
||||
|
||||
import com.ecwid.consul.transport.TLSConfig;
|
||||
import com.ecwid.consul.v1.ConsulClient;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.autoconfigure.health.ConditionalOnEnabledHealthIndicator;
|
||||
@@ -57,6 +59,17 @@ public class ConsulAutoConfiguration {
|
||||
? consulProperties.getScheme() + "://" + consulProperties.getHost()
|
||||
: consulProperties.getHost();
|
||||
|
||||
if (consulProperties.getTls() != null) {
|
||||
ConsulProperties.TLSConfig tls = consulProperties.getTls();
|
||||
TLSConfig tlsConfig = new TLSConfig(
|
||||
tls.getKeyStoreInstanceType(),
|
||||
tls.getCertificatePath(),
|
||||
tls.getCertificatePassword(),
|
||||
tls.getKeyStorePath(),
|
||||
tls.getKeyStorePassword()
|
||||
);
|
||||
return new ConsulClient(agentHost, agentPort, tlsConfig);
|
||||
}
|
||||
return new ConsulClient(agentHost, agentPort);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,10 @@ package org.springframework.cloud.consul;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import com.ecwid.consul.transport.TLSConfig.KeyStoreInstanceType;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.core.style.ToStringCreator;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/**
|
||||
@@ -41,6 +44,10 @@ public class ConsulProperties {
|
||||
/** Is spring cloud consul enabled */
|
||||
private boolean enabled = true;
|
||||
|
||||
/** configuration for TLS */
|
||||
private TLSConfig tls;
|
||||
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
@@ -73,13 +80,101 @@ public class ConsulProperties {
|
||||
this.scheme = scheme;
|
||||
}
|
||||
|
||||
public TLSConfig getTls() {
|
||||
return tls;
|
||||
}
|
||||
|
||||
public void setTls(TLSConfig tls) {
|
||||
this.tls = tls;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ConsulProperties{" +
|
||||
"host='" + host + '\'' +
|
||||
", port=" + port +
|
||||
", scheme=" + scheme +
|
||||
", tls=" + tls +
|
||||
", enabled=" + enabled +
|
||||
'}';
|
||||
}
|
||||
|
||||
public static class TLSConfig {
|
||||
/** Type of key framework to use. */
|
||||
private KeyStoreInstanceType keyStoreInstanceType;
|
||||
|
||||
/** Path to an external keystore */
|
||||
private String keyStorePath;
|
||||
|
||||
/** Password to an external keystore */
|
||||
private String keyStorePassword;
|
||||
|
||||
/**File path to the certificate. */
|
||||
private String certificatePath;
|
||||
|
||||
/** Password to open the certificate. */
|
||||
private String certificatePassword;
|
||||
|
||||
public TLSConfig() {
|
||||
}
|
||||
|
||||
public TLSConfig(KeyStoreInstanceType keyStoreInstanceType, String keyStorePath, String keyStorePassword, String certificatePath, String certificatePassword) {
|
||||
this.keyStoreInstanceType = keyStoreInstanceType;
|
||||
this.keyStorePath = keyStorePath;
|
||||
this.keyStorePassword = keyStorePassword;
|
||||
this.certificatePath = certificatePath;
|
||||
this.certificatePassword = certificatePassword;
|
||||
}
|
||||
|
||||
public KeyStoreInstanceType getKeyStoreInstanceType() {
|
||||
return keyStoreInstanceType;
|
||||
}
|
||||
|
||||
public void setKeyStoreInstanceType(KeyStoreInstanceType keyStoreInstanceType) {
|
||||
this.keyStoreInstanceType = keyStoreInstanceType;
|
||||
}
|
||||
|
||||
public String getKeyStorePath() {
|
||||
return keyStorePath;
|
||||
}
|
||||
|
||||
public void setKeyStorePath(String keyStorePath) {
|
||||
this.keyStorePath = keyStorePath;
|
||||
}
|
||||
|
||||
public String getKeyStorePassword() {
|
||||
return keyStorePassword;
|
||||
}
|
||||
|
||||
public void setKeyStorePassword(String keyStorePassword) {
|
||||
this.keyStorePassword = keyStorePassword;
|
||||
}
|
||||
|
||||
public String getCertificatePath() {
|
||||
return certificatePath;
|
||||
}
|
||||
|
||||
public void setCertificatePath(String certificatePath) {
|
||||
this.certificatePath = certificatePath;
|
||||
}
|
||||
|
||||
public String getCertificatePassword() {
|
||||
return certificatePassword;
|
||||
}
|
||||
|
||||
public void setCertificatePassword(String certificatePassword) {
|
||||
this.certificatePassword = certificatePassword;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringCreator(this)
|
||||
.append("keyStoreInstanceType", keyStoreInstanceType)
|
||||
.append("keyStorePath", keyStorePath)
|
||||
.append("keyStorePassword", keyStorePassword)
|
||||
.append("certificatePath", certificatePath)
|
||||
.append("certificatePassword", certificatePassword)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user