-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
advancedtls: adding AdvancedTlsX509TrustManager and AdvancedTlsX509KeyManager #8175
Conversation
Hi @ejona86 , this is the rest of the parts for the advancedtls code. Could you please take a look at it please? |
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
Some questions/comments:
|
@ejona86 Thanks for the review so far! There are still two remaining comments and I will work on fixing them the week after next week(Just FYI, I am OOO next week). |
@cfredri4 Please see my comments below.
Yeah, strictly speaking, this is a utility class, so it doesn't "fix" anything, but it did make reloading certificates easier in Java.
Sure! I think in general, contributions to support other key formats are welcome. Probably @ejona86 can help review it, or I can also review once I am back(I am OOO next week).
I am not entirely sure what kind of issues are in your mind. If using the classes here to build your credentials in Netty, we will use SimpleKeyManagerFactory as the key manager factory. This is a simple implementation without any caching mechanism, so I don't see any correlations with OpenSslCachingX509KeyManagerFactory, unless I miss something.
Sorry, I didn't get a chance to look at the full details of the code you pointed me, but it seems the file watcher you pointed me is also using a executor(https://github.com/cloudfoundry/java-buildpack-security-provider/blob/a70aa0c6e87e311fcb645ebd747864e33426d101/src/main/java/org/cloudfoundry/security/FileWatcher.java#L43). So I guess inherently both ways are similar? |
@ZhenLian ⬇️
Given the small change required, I added a gist here: https://gist.github.com/cfredri4/5655c1e54dc94f236054ec97b43e0a08
I had some recollection of seeing that OpenSslCachingX509KeyManagerFactory will wrap the given KeyManagerFactory and do caching, but after checking further it seems that this is only done when KeyManagerFactory has just been constructed from key material (not when given an existing KeyManagerFactory).
The difference is that with a file watcher, the thread is sleeping until the file is changed and then woken up, i.e. there is no polling being done and changes are immedately notified. |
@cfredri4 Sorry for the delay. I just got some time to work on this.
The changes look good to me overall. Feel free to open a PR for that, and we can iterate on that. We will also need some tests.
OK I see. We've considered both approaches(polling model or the notification model), but finally decided to go for the polling model, for the following reasons:
|
d1b79a9
to
76ee5b6
Compare
@ejona86 Hi Eric, I think I've fixed all the comments and the build failures. Can you please take another look again, please? Thank you so much! |
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
6930cac
to
321b2c4
Compare
Discussed outside of github. The KeyManager was looking better before the swap to KeyStore, although a KeyStore would be fine if we used KeyStore.Entry/PrivateKeyEntry; as-is though the KeyStore is pretty annoying and doesn't add much value. The TrustManager would be very well suited to mostly just save the delegate TrustManager as a field and delegate to it simply, instead of storing the KeyStore and the like. We also discussed the fact that the KeyManager is racy, because the API itself is racy when an alias mutates. There's an option to mostly avoid the race by changing the alias name each time we do an update, and keeping a previous update. But that might not be essential. |
8f4a297
to
8765c1f
Compare
@ejona86 Hi Eric, I've updated the code based on the discussion we had last Friday. Would you mind taking a look again please? Thank you so much for the review so far! |
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
core/src/main/java/io/grpc/util/AdvancedTlsX509TrustManager.java
Outdated
Show resolved
Hide resolved
Thanks again for the review! Merging now... |
This pull request adds the following classes to
io.grpc.util
:AdvancedTlsX509TrustManager
that supportsAdvancedTlsX509KeyManager
that supportsThis also adds the integration tests to
io.grpc.netty
.