Adds configuration properties for TLSConfig in ConsulClient.
fixes gh-360
This commit is contained in:
committed by
Spencer Gibb
parent
2d784ef775
commit
3b85ada2e4
@@ -16,7 +16,10 @@
|
||||
|
||||
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.ConditionalOnEnabledHealthIndicator;
|
||||
import org.springframework.boot.actuate.condition.ConditionalOnEnabledEndpoint;
|
||||
import org.springframework.boot.actuate.endpoint.Endpoint;
|
||||
@@ -32,8 +35,6 @@ import org.springframework.retry.annotation.Retryable;
|
||||
import org.springframework.retry.interceptor.RetryInterceptorBuilder;
|
||||
import org.springframework.retry.interceptor.RetryOperationsInterceptor;
|
||||
|
||||
import com.ecwid.consul.v1.ConsulClient;
|
||||
|
||||
/**
|
||||
* @author Spencer Gibb
|
||||
*/
|
||||
@@ -51,6 +52,17 @@ public class ConsulAutoConfiguration {
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public ConsulClient consulClient(ConsulProperties consulProperties) {
|
||||
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(consulProperties.getHost(), consulProperties.getPort(), tlsConfig);
|
||||
}
|
||||
return new ConsulClient(consulProperties.getHost(), consulProperties.getPort());
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.cloud.consul;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import com.ecwid.consul.transport.TLSConfig.KeyStoreInstanceType;
|
||||
import lombok.Data;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
@@ -40,4 +41,25 @@ public class ConsulProperties {
|
||||
|
||||
/** Is spring cloud consul enabled */
|
||||
private boolean enabled = true;
|
||||
|
||||
/** configuration for TLS */
|
||||
private TLSConfig tls;
|
||||
|
||||
@Data
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user