Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(agent): fix TLS enforcement for Agent instances #758

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
}
Loading