Repository navigation
Mutual TLS support - #6076
Mutual TLS support#6076
Conversation
gianm
left a comment
There was a problem hiding this comment.
This functionality should have a test of some sort: client cert validation is an important thing and we want to make sure it keeps working even if the code is refactored later in some way.
|
@gianm hm, I don't think we have any tests for TLS in general, I'll add some integration tests |
|
@jon-wei, thanks, I think it is really valuable especially as we add more features to the feature. (I heard you like features so we put features in your features?) |
|
@jon-wei Are you done working on this patch? I wasn't sure since the last few commits are named "WIP" |
|
Not yet, I made the integration tests use mutual TLS, but there's a test for coordinator -> overlord proxying that's failing, haven't fixed that yet |
|
Got it, thanks. |
29d43b4 to
b159728
Compare
|
I updated the patch with the following:
|
|
👍 |
gianm
left a comment
There was a problem hiding this comment.
Thanks @jon-wei. Please also include a couple of other features in the tests (I didn't see these, but if I missed them let me know).
- Different private keys and certs for the client and server. (Can be the same root CA, and same CN/altNames, but generate two different keys, and two different keyStores.)
- A negative test (getting the connection rejected in two cases: client cert missing; and client cert present, but CN/altName don't match the client hostname).
These are intended to verify that the certificate validation is being done properly by the https server.
There was a problem hiding this comment.
This won't be used for anything other than verifying client certificates?
There was a problem hiding this comment.
yes, the truststore on the server configuration side is only used to check the client certificates
There was a problem hiding this comment.
How about requireClientCertificate?
There was a problem hiding this comment.
Changed to requireClientCertificate
The services and clients have different keys/certs, I'll update the patch to rename the client files so that this is more apparent |
|
@jon-wei is this still a WIP or is it ready for re-review? |
cc3ae32 to
d1f9820
Compare
|
@gianm Still WIP, adjusting the networking in the integration tests for hostname verification, also looking into cert revocation handling |
| sslContextFactory.setNeedClientAuth(tlsServerConfig.isRequireClientCertificate()); | ||
| if (tlsServerConfig.isRequireClientCertificate()) { | ||
| if (tlsServerConfig.getCrlPath() != null) { | ||
| sslContextFactory.setValidatePeerCerts(true); |
There was a problem hiding this comment.
This is a pretty crazy API on Jetty's part: it looks like that the only thing setValidatePeerCerts does is turn on CRL checking. Is that right? If so, the method is definitely not named intuitively. Could you add a comment about this?
I'm asking because at first glance, it looks like a bug, even if it's not.
There was a problem hiding this comment.
Added a comment here
| if (tlsServerConfig.getTrustStorePath() != null) { | ||
| sslContextFactory.setTrustStorePath(tlsServerConfig.getTrustStorePath()); | ||
| sslContextFactory.setTrustStoreType( | ||
| tlsServerConfig.getTrustStoreType() == null ? |
There was a problem hiding this comment.
nit: formatting is a little strange here, and in similar statements below.
There was a problem hiding this comment.
Reformatted these areas
| @@ -39,28 +44,77 @@ public static SSLContext createSSLContext( | |||
| String trustStoreType, | |||
There was a problem hiding this comment.
Looks like the trust store parameters should be marked @Nullable.
There was a problem hiding this comment.
Marked the nullable params @Nullable
| PasswordProvider trustStorePasswordProvider | ||
| PasswordProvider trustStorePasswordProvider, | ||
| String keyStoreType, | ||
| String keyStorePath, |
There was a problem hiding this comment.
Looks like the key store parameters should be marked @Nullable too. Maybe some other parameters as well?
There was a problem hiding this comment.
Marked the nullable params @Nullable
| @Path("/status") | ||
| public class StatusResource | ||
| { | ||
| private static Logger log = new Logger(StatusResource.class); |
| String keyStoreAlgorithm, | ||
| String certAlias, | ||
| PasswordProvider keyStorePasswordProvider, | ||
| PasswordProvider keyManagerFactoryPasswordProvider |
There was a problem hiding this comment.
This method's arg list is getting super long. It would be nicer, although not required, to use a builder instead.
There was a problem hiding this comment.
Added a builder and replaced constructor calls with builder use
| |`druid.server.https.trustStorePath`|The file path or URL of the trust store containing certificates used to validate client certificates. Not needed if `requireClientCertificate` is false.|none|yes, only if `requireClientCertificate` is true| | ||
| |`druid.server.https.trustStoreAlgorithm`|Algorithm to be used by TrustManager to validate client certificate chains. Not needed if `requireClientCertificate` is false.|`javax.net.ssl.TrustManagerFactory.getDefaultAlgorithm()`|no| | ||
| |`druid.server.https.trustStorePassword`|The [Password Provider](../../operations/password-provider.html) or String password for the Trust Store. Not needed if `requireClientCertificate` is false.|none|no| | ||
| |`druid.server.https.validateHostnames`|If set to true, perform hostname validation on client certificates. Not used if `requireClientCertificate` is false.|false|no| |
There was a problem hiding this comment.
What does "hostname validation" mean in this context? If it means checking CN/altNames, then it should be true by default, since otherwise it's a trap waiting to be sprung on people.
(Once you turn on druid.server.https.requireClientCertificate, we should be secure as possible by default, and you should have to explicitly set options to be less secure.)
There was a problem hiding this comment.
Changed default to true and added more details to the documentation
|
Addressed comments, also adjusted |
* Mutual TLS support * Kafka test fixes * TeamCity fix * Split integration tests * Use localhost DOCKER_IP * Increase server thread count * Increase SSL handshake timeouts * Add broken pipe retries, use injected client config params * PR comments, Rat license check exclusion
* Mutual TLS support * Kafka test fixes * TeamCity fix * Split integration tests * Use localhost DOCKER_IP * Increase server thread count * Increase SSL handshake timeouts * Add broken pipe retries, use injected client config params * PR comments, Rat license check exclusion
This PR adds support for mutual TLS (https://en.wikipedia.org/wiki/Mutual_authentication).
This adds a new "requireClientAuth" property and truststore properties on the server-side TLS config.
If "requireClientAuth" is true, Druid will require clients to identify themselves by providing a TLS certificate.
The server-side truststore needs to be configured with the certificates needed to validate the client certificates.
On the client side for internal communications (
simple-client-sslcontextextension), new keystore properties are added, specifying the client certificate that a Druid service will use when communicating with other Druid services.