Skip to content

Commit

Permalink
Handle TLS settings for Eureka Server's JerseyClient. (#4285)
Browse files Browse the repository at this point in the history
  • Loading branch information
OlgaMaciaszek authored Jul 2, 2024
1 parent f47e93c commit b43fa21
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.net.MalformedURLException;
import java.net.URL;
import java.net.UnknownHostException;
import java.security.GeneralSecurityException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
Expand Down Expand Up @@ -88,6 +89,8 @@
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.cloud.client.actuator.HasFeatures;
import org.springframework.cloud.configuration.SSLContextFactory;
import org.springframework.cloud.configuration.TlsProperties;
import org.springframework.cloud.context.environment.EnvironmentChangeEvent;
import org.springframework.cloud.netflix.eureka.EurekaConstants;
import org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean;
Expand All @@ -112,6 +115,7 @@
* @author Fahim Farook
* @author Weix Sun
* @author Robert Bleyl
* @author Olga Maciaszek-Sharma
*/
@Configuration(proxyBeanMethods = false)
@Import(EurekaServerInitializerConfiguration.class)
Expand Down Expand Up @@ -205,8 +209,14 @@ public Jersey3EurekaServerHttpClientFactory jersey3EurekaServerHttpClientFactory

@Bean
@ConditionalOnMissingBean(AbstractDiscoveryClientOptionalArgs.class)
public Jersey3DiscoveryClientOptionalArgs jersey3DiscoveryClientOptionalArgs() {
return new Jersey3DiscoveryClientOptionalArgs();
public Jersey3DiscoveryClientOptionalArgs jersey3DiscoveryClientOptionalArgs(
@Autowired(required = false) TlsProperties tlsProperties) throws GeneralSecurityException, IOException {
Jersey3DiscoveryClientOptionalArgs optionalArgs = new Jersey3DiscoveryClientOptionalArgs();
if (tlsProperties != null && tlsProperties.isEnabled()) {
SSLContextFactory factory = new SSLContextFactory(tlsProperties);
optionalArgs.setSSLContext(factory.createSSLContext());
}
return optionalArgs;
}

@Bean
Expand Down

0 comments on commit b43fa21

Please sign in to comment.