Skip to content

Conversation

@SylvainJuge
Copy link
Contributor

@SylvainJuge SylvainJuge commented Feb 7, 2025

This is based on #1684 which is not merged yet, I'll rebase to minimize the diff once it's merged.

Part of #1681

This adds the following features with proper integration tests for JMX with SSL:

  • SSL enabled on server, server certificate must be trusted on the client
  • SSL enabled on server with SSL RMI registry
  • SSL enabled on server with client SSL certificate

Using other advanced JAAS configuration options for authentication is not part of this PR and will be implemented in a separate PR.

@SylvainJuge SylvainJuge force-pushed the jmx-scraper-server-ssl branch from 129ed8b to 057ba99 Compare February 17, 2025 13:27
Comment on lines +163 to +183
logger.info("Connecting with SSL protected RMI registry to " + url);
String hostName;
int port;

if (url.getURLPath().startsWith("/jndi/")) {
String[] components = url.getURLPath().split("/", 3);
URI uri = URI.create(components[2]);
hostName = uri.getHost();
port = uri.getPort();
} else {
hostName = url.getHost();
port = url.getPort();
}

try {
JMXConnector jmxConn = new RMIConnector(getStub(hostName, port), null);
jmxConn.connect(env);
return jmxConn;
} catch (IOException e) {
throw new IllegalStateException("Unable to connect to " + url, e);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[for reviewer] copied almost as-is from jmx gatherer

@SylvainJuge SylvainJuge marked this pull request as ready for review February 17, 2025 15:18
@SylvainJuge SylvainJuge requested a review from a team February 17, 2025 15:18
}

private void addKeyStore(
Path path, String password, boolean keyStore, Map<String, String> properties) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boolean keyStore could be StoreTypeEnum storeType, where StoreTypeEnum would be KEY_STORE, TRUST_STORE

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having any kind of strong typing is not really necessary here IMHO as there are only a few use-cases so I think a boolean is fine. We could also have introduced dedicated interfaces for trust and key stores but in practice it's the same file and only the usage we make of it makes it either a trust or a key store, we could even use a single key store for both trusted certificates and storing key pairs.

@trask trask merged commit 4ce7187 into open-telemetry:main Feb 19, 2025
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants