-
Notifications
You must be signed in to change notification settings - Fork 814
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
Added cleaner SSL support to HTTPServer #695
Conversation
37612fc
to
638e2ce
Compare
Hi, thanks a lot for the PR, and sorry for the delay. I have this on the top of my TODO list, and I am planning to get back to it this week. |
Here are a few initial thoughts: First of all, thank you very much for digging into this, SSL is really an ugly part of Java's API. I think it's worthwhile to step back a bit and look at how SSL should be configured from a user's perspective, for example in Compatibility with node_exporterMy first thought was, let's make SSL configuration similar to tls_server_config:
cert_file: node_exporter.crt
key_file: node_exporter.key It would be great if there was an easy way to use these I will research this a bit more, because it would be great if we could provide a consistent way of configuring SSL across different exporters. Compatibility with Java's default behaviorIf we cannot follow the
It turns out, if you use the default ((HttpsServer) httpServer).setHttpsConfigurator(new HttpsConfigurator(SSLContext.getDefault())); Then create a key store with
Then start the Server with As this works I'm wondering: Do we need the custom |
I'll do some more research as well on the use of a Regarding the use of system properties, I feel...
I can see scenarios where there are requirements (InfoSec) to use different certificates. Example - Given a machine with two hostnames/IP addresses, I want the application to use hostname 1/IP address 1/certificate 1 and the |
Hi @dhoard, thanks for the update. Regarding security: I don't think that system properties are necessarily insecure, because if you want to avoid command line parameters you can set them programmatically as well with However, it's true that if SSL is configured via system properties, the configuration will apply to the rest of the application as well. Maybe we should offer both ways, a simple I'm wondering how much of new HttpsConfigurator(sslContext); It works (at least the test is green when I do this), so I'm wondering if overriding Regarding the I'm not sure whether there is a good solution for an SSL configuration API. I'm wondering if we should remove What do you think? |
@fstab all good points. I think we should add the Then, I think we should remove the This would allow creating a |
The question is how much value our own |
The current value is encapsulating all the boilerplate code that every developer would duplicate if they want to use SSL with a keystore. Once we can determine how to use a PEM certificate(s) it will allow that encapsulation as well. |
There are some libraries out there for creating I fear if we make our API sufficiently flexible we will end up writing our own library like this, which would be out of scope for |
@fstab I understand your point of view. To me, SSL support seems like a core functionality when using There are really two thoughts/approaches...
We need to reconcile the approach with |
I feel we should stick with the built-in |
@fstab fair enough. I'll try to make the changes this week. |
@fstab changes made per our converstation. Please review. |
@fstab Thoughts on merging this PR? |
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.
Thanks a lot and sorry for the delay. It's looking good, I just commented two nitpicks.
Please also rebase it to the current master
.
I'm happy to merge and release it so we can use it in jmx_exporter
.
Thanks you for your patience!
simpleclient_httpserver/src/main/java/io/prometheus/client/exporter/HTTPServer.java
Outdated
Show resolved
Hide resolved
simpleclient_httpserver/src/main/java/io/prometheus/client/exporter/HTTPServer.java
Outdated
Show resolved
Hide resolved
Thanks a lot! Would you mind rebasing the branch to the current master? Automatic rebase fails because of merge conflicts. This branch has 10 commits, and I think for later reference it would be easier to squash them into one and rebase them on the current master. BTW I just published a release so that people don't have the vulnerable log4j dependency in their dependency anymore. However, that does not mean that we need to wait for long until we create a new release with the SSL support. I'd say as soon as we want to merge code in |
Signed-off-by: Doug Hoard <doug.hoard@gmail.com>
Thanks a lot! |
It's released with 0.14.0 🎉. |
Added cleaner SSL support to
HTTPServer
.This will allow downstream projects to set up an
SSLContext
and use it with theHTTPServer.Builder
via thewithSSLContext(SSLContext sslContext)
method to support SSL.Added public static helper method
HTTPServer.createSSLContext(String sslContextType, String keyStoreType, String keyStorePath, String keyStorePassword)
to create anSSLContext
for the most common use-cases.