Skip to content

Commit

Permalink
fix(agent): fix TLS enforcement for Agent instances
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores committed Jan 15, 2025
1 parent f4e2a5e commit 4678a6e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/main/java/io/cryostat/targets/AgentConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ class AgentConnection implements JFRConnection {
private final TemplateService customTemplateService;
private final Logger logger = Logger.getLogger(getClass());

@ConfigProperty(name = ConfigProperties.AGENT_TLS_REQUIRED)
private static boolean TLS_REQUIRED;

AgentConnection(AgentClient client, TemplateService customTemplateService) {
this.client = client;
this.customTemplateService = customTemplateService;
Expand Down Expand Up @@ -158,19 +155,21 @@ public MBeanMetrics getMBeanMetrics()
@ApplicationScoped
public static class Factory {

@ConfigProperty(name = ConfigProperties.AGENT_TLS_REQUIRED)
boolean tlsRequired;

@Inject AgentClient.Factory clientFactory;
@Inject S3TemplateService customTemplateService;
@Inject Logger logger;

public AgentConnection createConnection(Target target) throws MalformedURLException {
if (TLS_REQUIRED && target.connectUrl.getScheme().equals("https")) {
return new AgentConnection(clientFactory.create(target), customTemplateService);
} else {
if (tlsRequired && !target.connectUrl.getScheme().equals("https")) {
throw new MalformedURLException(
String.format(
"Agent connections are required to be TLS by (%s)",
ConfigProperties.AGENT_TLS_REQUIRED));
}
return new AgentConnection(clientFactory.create(target), customTemplateService);
}
}
}

0 comments on commit 4678a6e

Please sign in to comment.