- 
                Notifications
    You must be signed in to change notification settings 
- Fork 168
jmx-scraper add ssl support #1710
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
jmx-scraper add ssl support #1710
Conversation
129ed8b    to
    057ba99      
    Compare
  
    | 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); | ||
| } | 
There was a problem hiding this comment.
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
        
          
                jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/JmxConnectionTest.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/JmxConnectionTest.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
              
          
                jmx-scraper/src/integrationTest/java/io/opentelemetry/contrib/jmxscraper/TestAppContainer.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
      | } | ||
|  | ||
| private void addKeyStore( | ||
| Path path, String password, boolean keyStore, Map<String, String> properties) { | 
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
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:
Using other advanced JAAS configuration options for authentication is not part of this PR and will be implemented in a separate PR.