Skip to content

Commit 48eacd0

Browse files
authored
fix(agent): fix TLS enforcement for Agent instances (#758)
1 parent f4e2a5e commit 48eacd0

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/main/java/io/cryostat/targets/AgentConnection.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ class AgentConnection implements JFRConnection {
5151
private final TemplateService customTemplateService;
5252
private final Logger logger = Logger.getLogger(getClass());
5353

54-
@ConfigProperty(name = ConfigProperties.AGENT_TLS_REQUIRED)
55-
private static boolean TLS_REQUIRED;
56-
5754
AgentConnection(AgentClient client, TemplateService customTemplateService) {
5855
this.client = client;
5956
this.customTemplateService = customTemplateService;
@@ -158,19 +155,21 @@ public MBeanMetrics getMBeanMetrics()
158155
@ApplicationScoped
159156
public static class Factory {
160157

158+
@ConfigProperty(name = ConfigProperties.AGENT_TLS_REQUIRED)
159+
boolean tlsRequired;
160+
161161
@Inject AgentClient.Factory clientFactory;
162162
@Inject S3TemplateService customTemplateService;
163163
@Inject Logger logger;
164164

165165
public AgentConnection createConnection(Target target) throws MalformedURLException {
166-
if (TLS_REQUIRED && target.connectUrl.getScheme().equals("https")) {
167-
return new AgentConnection(clientFactory.create(target), customTemplateService);
168-
} else {
166+
if (tlsRequired && !target.connectUrl.getScheme().equals("https")) {
169167
throw new MalformedURLException(
170168
String.format(
171169
"Agent connections are required to be TLS by (%s)",
172170
ConfigProperties.AGENT_TLS_REQUIRED));
173171
}
172+
return new AgentConnection(clientFactory.create(target), customTemplateService);
174173
}
175174
}
176175
}

0 commit comments

Comments
 (0)